Results 1 to 3 of 3

Thread: GUI not displaying

  1. #1
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Red face GUI not displaying

    I have been trying to get a GUI to display inside Qt 3.3.7 and I have designed it off other classes I have successfully created. But for some reason all I see in this QDialog is the very first item I add to the layout. Here is my code for the constructor and the createGui function. Sorry if there is a typo as my coding machine is not hooked up online so I have to retype all my code to show on here. Thanks for your help!

    Qt Code:
    1. ScreeningDialog::ScreeningDialog( Configuration *conf, QWidget *parent ) : QDialog( parent )
    2. {
    3. createGui( );
    4. mpConfiguration = config;
    5. mScreeningLocation = mpConfiguration->getScreeningExe( );
    6.  
    7. setPalette( parent->palette( ) );
    8. }
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void ScreeningDialog::createGui( )
    2. {
    3. QWidget *mainWidget = new QWidget( this );
    4. QGridLayout = new QGridLayout( mainWidget );
    5.  
    6. QLabel *outputDirLabel = new QLabel( tr( "Output Directory:" ), mainWidget );
    7. mpOutputDirLnEd = new QLineEdit( mainWidget );
    8. QPushButton *outputButton = new QPushButton( tr( "Open" ), mainWidget );
    9. connect( outputButton, SIGNAL( clicked( ) ), this, SLOT( openDirPressed( ) ) );
    10.  
    11. QLabel *confFileLabel = new QLabel( tr( "Configuration File:" ), mainWidget );
    12. mpConfFileLnEd = new QLineEdit( mainWidget );
    13. QPushButton *confButton = new QPushButton( tr( "Open" ), mainWidget );
    14. connect( confButton, SIGNAL( clicked( ) ), this, SLOT( openFilePressed( ) ) );
    15.  
    16. QGroupBox *methodBox = new QGroupBox( tr( "Method" ), mainWidget );
    17. QVBoxLayout *methodLayout = new QVBoxLayout( methodBox );
    18. QButtonGroup *methodGroup = new QButtonGroup( );
    19. methodGroup->setExclusive( true );
    20. mpWidthCB = new QCheckBox( tr( "Width" ), methodBox );
    21. mpAutoCB = new QCheckBox( tr( "Auto" ), methodBox );
    22.  
    23. methodGroup->insert( mpWidthCB );
    24. methodGroup->insert( mpAutoCB );
    25.  
    26. methodLayout->addWidget( mpWidthCB );
    27. methodLayout->addWidget( mpAutoCB );
    28.  
    29. QPushButton *executeButton = new QPushButton( tr( "Execute" ), mainWidget );
    30. connect( executeButton, SIGNAL( clicked( ) ), this, SLOT( executePressed( ) ) );
    31. QPushButton *cancelButton = new QPushButton( tr( "Cancel" ), mainWidget );
    32. connect( cancelButton, SIGNAL( clicked( ) ), this, SLOT( cancelPressed( ) ) );
    33.  
    34. mainLayout->addWidget( outputDirLabel, 0, 0 );
    35. mainLayout->addWidget( mpOutputDirLnEd, 0, 1 );
    36. mainLayout->addWidget( outputButton, 0, 2 );
    37. mainLayout->addWidget( confFileLabel, 1, 0 );
    38. mainLayout->addWidget( mpConfFileLnEd, 1, 1 );
    39. mainLayout->addWidget( confButton, 1, 2 );
    40. mainLayout->addWidget( methodBox, 2, 0 );
    41. mainLayout->addWidget( executeButton, 3, 1 );
    42. mainLayout->addWidget( cancelButton, 3, 2 );
    43. }
    To copy to clipboard, switch view to plain text mode 

    I cannot figure why the only thing I see when I open the dialog is the label that says "Output Directory:". Thanks for all your help with getting my dialog to display correctly!

  2. #2
    Join Date
    Mar 2006
    Location
    Mexico City
    Posts
    31
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Angry Re: GUI not displaying

    Hi ToddAtWSU:

    Why are you using 'mainWidget'?

    As far as I can see, you are using a QWidget inside a QWidget. Your class ScreeningDialog is a QWidget, so yo can then omit:

    Qt Code:
    1. QWidget *mainWidget = new QWidget( this );
    To copy to clipboard, switch view to plain text mode 
    and use 'this' insted of 'mainWidget'. For example:
    Qt Code:
    1. .....
    2. QGridLayout = new QGridLayout( this );
    3. QLabel *outputDirLabel = new QLabel( tr( "Output Directory:" ), this );
    4. mpOutputDirLnEd = new QLineEdit( this );
    5. ....
    To copy to clipboard, switch view to plain text mode 

    I think that may be your problem...

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

    ToddAtWSU (22nd February 2007)

  4. #3
    Join Date
    Jan 2006
    Location
    Ohio
    Posts
    332
    Thanks
    37
    Thanked 8 Times in 4 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: GUI not displaying

    Thanks! That worked. I don't know why my way didn't work because on other dialogs I had created a mainWidget like I did here and it always worked fine. That is why I was so frustrated with this one, it was identical to how I set up other QDialogs but oh well...it worked with using "this" all the time. Thanks for your help!

Similar Threads

  1. Displaying real time images
    By Sheetal in forum Qt Programming
    Replies: 9
    Last Post: 22nd February 2007, 11:29
  2. displaying png image for a given area..
    By sar_van81 in forum Qt Programming
    Replies: 1
    Last Post: 17th January 2007, 13:56
  3. displaying any table on a qdatatable
    By Philip_Anselmo in forum Newbie
    Replies: 4
    Last Post: 9th May 2006, 22:12
  4. std::cout displaying a hex value instead of a string.
    By johnny_sparx in forum Qt Programming
    Replies: 2
    Last Post: 8th April 2006, 08:55
  5. QTAbBar not displaying
    By Dune in forum Qt Programming
    Replies: 17
    Last Post: 9th February 2006, 18:25

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.