qt-interest@trolltech.com
[Top] [All Lists]

Re: login application in qt

Subject: Re: login application in qt
From: Houssem BDIOUI
Date: Thu, 14 Jul 2005 09:02:26 +0200
 
Are you sure you're new to Qt? :)
OK, first of all please always put in copy qt-interest (others may be interested).
Then, you don't have to write everything yourself; Use designer instead
to create the dialog for you and the uic utility will generate the code.
You'll gain a lot of time this way. You'll still have to create the main.cpp
 
You then need to subclass the dialog to re-implement the accept()
virtual slot.
 
Ciao

 
2005/7/14, Sailaja.Mulakaluri <sailaja.mulakaluri@xxxxxxxxxxxxxxxxxxx>:
I have written some code. I have not connected the signals and slots.
Just displaying.
Please check out if any error and get back.

login.h
-------
#ifndef LINEDIT_H
#define LINEDIT_H

#include <qgroupbox.h>
class QLineEdit;
class LineEdit : public QGroupBox
{
   Q_OBJECT

public:
   LineEdit( QWidget *parent = 0, const char *name = 0 );
protected:
   QLineEdit *lined1, *lined2;
protected slots:
   void slotEchoChanged();
   void slotDisplayText();
}
#endif


login.cpp
---------
#include "login.h"

#include < qlineedit.h>
#include <qcombobox.h>
#include <qframe.h>
#include <qvalidator.h>
#include <qlabel.h>
#include <qlayout.h>
#include <qhbox.h>

LineEdit::LineEdit( QWidget *parent, const char *name )
{
   setMargin( 10 );

QHBoxLayout *box = new QHBoxLayout( layout() );
QHBoxLayout *row1 = new QHBoxLayout( box );
   row1->setMargin( 5 );
QLabel* label = new QLabel( "UserName: ", this);
   row1->addWidget( label );
lined1 = new QLineEdit( this );
   box->addWidget( lined1 );
QHBoxLayout *row2 = new QHBoxLayout( box );
QLabel * label2 = new QLabel( "Password ", this );
   row2->addWidget( label2 );
lined2 = new QLineEdit ( this );
   box->addWidget( lined2);
}


void LineEdit::slotEchoChanged()
{
       lined2->setEchoMode( QLineEdit::Password );

lined2->setFocus();
}
void LineEdit::slotDisplayText()
{
       lined1->setEchomode(  QLineEdit::displayText ())
-----------------------------------------
//can i use like above to display text?//
---------------------------------------

main.cpp
--------
#include "login.h"
#include <qapplication.h>

int main( int argc, char **argv )
{
   QApplication a( argc, argv );

   LineEdit line;
   line.setCaption( "Login example" );
   a.setMainWidget( &line );
   line.show();

   return a.exec();
}

On Thu, 2005-07-14 at 08:45 +0200, Houssem BDIOUI wrote:
> Sailaja,
>
>    We can sure do the work for you but you won't learn anything.
> Assistant (the Qt online documentation program) is your friend.
> And start also with the tutorial located in $QTDIR.
>
> Good luck
>
>
> 2005/7/14, Sailaja.Mulakaluri <sailaja.mulakaluri@host -
> technology.com>:
>         Hello everyone,
>                        I am new to Qt and I want to learn it.
>         First of all, I desire to create a login application
>         |--------------------|
>         |USER NAME : textbox |
>         |PASSWORD : textbox  |
>         |
>         |SUBMIT    CANCEL    |
>         ----------------------
>         this is the format of the QT application.
>         Now, when I press SUBMIT button, I should get the text
>         displayed in both
>         the username and passsword text boxes.
>         As I am new to all these signals and slots, Can anyone suggest
>         me a good
>         tutorial or any online book on QT.
>
>         If possible please do send me the code snippets for the above
>         application i ahve mentioned.
>
>
>         --
>         Regards,
>         Sailaja
>
>
>
>
--
Regards,
Sailaja.Mulakaluri,
Software Engineer,
Host Technologies,
Hyderabad

"Never Answer a Critic Unless He Asks For It"



<Prev in Thread] Current Thread [Next in Thread>