Results 1 to 10 of 10

Thread: create login page

  1. #1
    Join Date
    Mar 2013
    Posts
    45
    Thanks
    23
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default create login page

    hi

    i want to create a login page .
    But this code does not work .

    setPass.h

    Qt Code:
    1. #ifndef SETPASS_H
    2. #define SETPASS_H
    3.  
    4. #include <QDialog>
    5.  
    6. namespace Ui {
    7. class setPass;
    8. }
    9.  
    10. class setPass : public QDialog
    11. {
    12. Q_OBJECT
    13.  
    14. public:
    15. explicit setPass(QWidget *parent = 0);
    16. ~setPass();
    17. void setPassword(QString &pass);
    18. void setUsername(QString &user);
    19. bool setBool();
    20.  
    21. private slots:
    22. void on_pushButton_clicked();
    23.  
    24. private:
    25. Ui::setPass *ui;
    26. QString pass , user ;
    27. bool res1 , res2 ;
    28.  
    29. };
    30.  
    31. #endif // SETPASS_H
    To copy to clipboard, switch view to plain text mode 

    setPass.cpp

    Qt Code:
    1. #include "setpass.h"
    2. #include "ui_setpass.h"
    3.  
    4. setPass::setPass(QWidget *parent) :
    5. QDialog(parent),
    6. ui(new Ui::setPass)
    7. {
    8. ui->setupUi(this);
    9. }
    10.  
    11. setPass::~setPass()
    12. {
    13. delete ui;
    14. }
    15.  
    16. void setPass::setPassword(QString &pass)
    17. {
    18.  
    19. QString c_pass = "123456";
    20. int a = c_pass.compare(pass);
    21. if(a == 0)
    22. res1 = true ;
    23. }
    24.  
    25. void setPass::setUsername(QString &user)
    26. {
    27.  
    28. QString c_user = "m";
    29. int a = c_user.compare(user);
    30. if( a == 0 )
    31. res2 = true ;
    32. }
    33.  
    34. void setPass::on_pushButton_clicked()
    35. {
    36. setUsername(user = ui->userName->text());
    37. setPassword( pass = ui->passWord->text());
    38. }
    39.  
    40. bool setPass::setBool()
    41. {
    42. if(res2 == true && res1 == true)
    43. return true ;
    44. else return false ;
    45. }
    To copy to clipboard, switch view to plain text mode 

    main.cpp

    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3. #include "dialog.h"
    4. #include "setpass.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. setPass pas ;
    11. pas.show();
    12. if(pas.setBool())
    13. {
    14. MainWindow w;
    15. pas.close();
    16. w.show();
    17. }
    18. return a.exec();
    19. }
    To copy to clipboard, switch view to plain text mode 

    pic:

    68799751914376939931.jpg

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: create login page

    Call pas.exec(); instead of pas.show();
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

  3. The following user says thank you to Santosh Reddy for this useful post:

    smemamian (20th April 2013)

  4. #3
    Join Date
    Mar 2013
    Posts
    45
    Thanks
    23
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: create login page

    ok, but when i click on ok button, the user and pass window does not close ! Then when I close the user and pass window manually, The main window opens.

  5. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: create login page

    Qt Code:
    1. void setPass::on_pushButton_clicked()
    2. {
    3. setUsername(user = ui->userName->text());
    4. setPassword( pass = ui->passWord->text());
    5. accept(); // <<<<<<<<<<<<
    6. }
    To copy to clipboard, switch view to plain text mode 
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  6. The following user says thank you to amleto for this useful post:

    smemamian (20th April 2013)

  7. #5
    Join Date
    Mar 2013
    Posts
    45
    Thanks
    23
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: create login page

    Does not work,when i click ok button, the user and pass window is closed !

  8. #6
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: create login page

    Quote Originally Posted by smemamian View Post
    ok, but when i click on ok button, the user and pass window does not close ! Then when I close the user and pass window manually, The main window opens.
    Quote Originally Posted by smemamian View Post
    Does not work,when i click ok button, the user and pass window is closed !
    Make up your mind...
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  9. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: create login page

    Why wouldn't it be closed?

    @amleto: I think he doesn't want to close the dialog until the user explicitly requests so. Which doesn't make much sense but I think that's OP's idea...
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  10. #8
    Join Date
    Mar 2013
    Posts
    45
    Thanks
    23
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

  11. #9
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: create login page

    going back to this
    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3. #include "dialog.h"
    4. #include "setpass.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. setPass pas ;
    11. pas.show();
    12. if(pas.setBool())
    13. {
    14. MainWindow w;
    15. pas.close();
    16. w.show();
    17. }
    18. // what do you think has happened to 'w' here? Answer: it does not exist.
    19. return a.exec();
    20. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. #include "mainwindow.h"
    2. #include <QApplication>
    3. #include "dialog.h"
    4. #include "setpass.h"
    5.  
    6. int main(int argc, char *argv[])
    7. {
    8. QApplication a(argc, argv);
    9.  
    10. setPass pas ;
    11. pas.exec(); // exec not close
    12. if(pas.setBool())
    13. {
    14. MainWindow w;
    15. //pas.close(); // this is already closed
    16. w.show();
    17.  
    18. return a.exec();
    19. }
    20.  
    21. return 1;
    22. }
    To copy to clipboard, switch view to plain text mode 
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  12. The following user says thank you to amleto for this useful post:

    smemamian (20th April 2013)

  13. #10
    Join Date
    Mar 2013
    Posts
    45
    Thanks
    23
    Qt products
    Qt5
    Platforms
    Unix/X11 Windows

    Default Re: create login page

    i changed :
    Qt Code:
    1. void setPass::on_pushButton_clicked()
    2. {
    3. setUsername(user = ui->userName->text());
    4. setPassword( pass = ui->passWord->text());
    5. if(setBool())
    6. accept();
    7. }
    To copy to clipboard, switch view to plain text mode 

    Thank you all.
    Last edited by smemamian; 20th April 2013 at 19:56.

Similar Threads

  1. Replies: 2
    Last Post: 16th November 2012, 02:39
  2. Replies: 7
    Last Post: 15th November 2012, 14:22
  3. Load a simple Page after the Main Page.
    By mrhevor in forum Qt Quick
    Replies: 1
    Last Post: 27th September 2011, 10:32
  4. Creating Login page
    By yuvaraj.yadav in forum Newbie
    Replies: 2
    Last Post: 13th April 2009, 11:37

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.