Results 1 to 5 of 5

Thread: open a window according to the type chosen in mainwindow

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,321
    Thanks
    316
    Thanked 871 Times in 858 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: open a window according to the type chosen in mainwindow

    I think anda_skoa means something like this:

    Qt Code:
    1. // pseudocode
    2. void MainWindow::on_pushButton_3_clicked()
    3. {
    4. switch ( userType )
    5. {
    6. case User:
    7. showUserWindow();
    8. break;
    9.  
    10. case Doctor:
    11. showDoctorWindow();
    12. break;
    13.  
    14. case Administrator:
    15. showAdminWindow();
    16. break;
    17.  
    18. default:
    19. // error - no such user type
    20. break;
    21. }
    22. }
    To copy to clipboard, switch view to plain text mode 

    Obviously, your code will store the "userType" based on the previous button the user clicked.

    By the way, "pushButton_3" is a pretty bad name for a variable. A year from now, when you have to fix something in this code, will you remember which GUI button is the one named "pushButton_3" in the code? You'd probably have a much easier job if it were named "connectButton" or "joinButton" instead.
    Last edited by d_stranz; 23rd December 2016 at 23:07.
    <=== The Great Pumpkin says ===>
    Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.

Similar Threads

  1. Replies: 2
    Last Post: 14th January 2013, 07:07
  2. Replies: 0
    Last Post: 9th May 2010, 20:49
  3. Open Dialog from MainWindow.
    By halvors in forum Qt Programming
    Replies: 8
    Last Post: 1st April 2010, 01:09
  4. Open mainwindow
    By cwnelatury in forum Newbie
    Replies: 1
    Last Post: 17th April 2009, 22:46
  5. couldn't open fontconfigs chosen font with Xft!!!
    By Kenneth Freidank in forum Qt Programming
    Replies: 0
    Last Post: 5th October 2006, 03:14

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
  •  
Qt is a trademark of The Qt Company.