ToddAtWSU
11th January 2007, 16:26
I have converted my Qt 4.2 project down to Qt 3.3 as I was tasked. Of course nothing appeared like it did in my Qt 4.2 project so now it's time to debug and get it back to the way it was, but at least I can compile and get something to display. In my Main GUI, I have a label at the top-right, label in the bottom-left and a QSplitter in the middle. On the right side of the splitter I plan for 4 QGroupBoxes and on the left one QTable. Right now I am trying to get my 4 group boxes to show, and the middle two boxes are empty in the beginning...stuff is entered into them based on user interactions later on. The first problem I have is I don't see any titles on the QGroupBoxes and some of the members of the bottom QGroupBox is in between members of the top QGroupBox. And since I can't see any QGroupBox titles, I don't know if my empty boxes are being drawn. Here are some snippets of my code:
Inside my function MainWindow::createGUI
QFrame *mainFrame = new QFrame( this );
QVBoxLayout *mainLayout = new QVBoxLayout( mainFrame );
QSplitter *mainSplitter = new QSplitter( Qt::Horizontal );
QFrame *constraintFrame = new QFrame( mainSplitter );
QVBoxLayout *constraintLayout = new QVBoxLayout( constraintFrame );
...
createBox1( );
createBox2( );
createBox3( );
createBox4( );
constraintLayout->addWidget( mpBox1 );
constraintLayout->addWidget( mpBox2 );
constraintLayout->addWidget( mpBox3 );
constraintLayout->addWidget( mpBox4 );
...
setCentralWidget( mainFrame );
bool MainWindow::createBox1( )
{
mpBox1 = new QGroupBox( tr( "Display Constraints" ) );
QGridLayout *layout1 = new QGridLayout( mpBox1 );
QLabel *collectorsLabel = new QLabel( tr( "Collectors" ), this );
QLabel *minLabel = new QLabal( tr( "Min1:" ), this );
QLabel *maxLabel = new QLabel( tr( "Max1:" ), this );
mCollectorsBox = new QComboBox( this );
mMinLineEdit = new QLineEdit( this );
mMaxLineEdit = new QLineEdit( this );
mCollectorsBox->insertItem( tr( "1" ) );
mCollectorsBox->insertItem( tr( "2" ) );
mCollectorsBox->insertItem( tr( "3" ) );
mCollectorsBox->insertItem( tr( "4" ) );
mCollectorsBox->insertItem( tr( "5" ) );
layout1->addMultiCellWidget( collectorsLabel, 0, 0, 0, 1 );
layout1->addMultiCellWidget( mCollectorsBox, 0, 0, 3, 3 );
layout1->addMultiCellWidget( minLabel, 1, 1, 0, 0, Qt::AlignCenter );
layout1->addMultiCellWidget( mMinLineEdit, 1, 1, 1, 3 );
layout1->addMultiCellWidget( maxLabel, 2, 2, 0, 0, Qt::AlignCenter );
layout1->addMultiCellWidget( mMaxLineEdit, 2, 2, 1, 3 );
return true;
}
bool MainWindow::createBox4( )
{
mpBox4 = new QGroupBox( tr( "Section Constraints" ) );
QGridLayout *layout4 = new QGridLayout( mpBox4 );
QLabel *minLabel = new QLabal( tr( "Min2:" ), this );
QLabel *maxLabel = new QLabel( tr( "Max2:" ), this );
mMinSectionLineEdit = new QLineEdit( this );
mMaxSectionLineEdit = new QLineEdit( this );
layout1->addMultiCellWidget( minLabel, 0, 0, 0, 0, Qt::AlignCenter );
layout1->addMultiCellWidget( mMinSectionLineEdit, 0, 0, 1, 1 );
layout1->addMultiCellWidget( maxLabel, 1, 1, 0, 0, Qt::AlignCenter );
layout1->addMultiCellWidget( mMaxSectionLineEdit, 1, 1, 1, 1 );
return true;
}
Any of the members that begin with "mp" are member-pointers of my class and any object that begins with "m" is a class member with the exception of minLabal and maxLabel. When I run the program the main part of my window looks like:
collectorsLabel mCollectorsBox
Min2: mMinSectionLineEdit
Min1: mMinLineEdit
Max2: mMaxSectionLineEdit
Max1: mMaxLineEdit
My plan is for it to look like:
GroupBox1
collectorsLabel mCollectorsBox
Min1: mMinLineEdit
Max1: mMaxLineEdit
GroupBox2
GroupBox3
GroupBox4
Min2: mMinSectionLineEdit
Max2: mMaxSectionLineEdit
Like I said GroupBox2 and GroupBox3 are empty when I first load the program but the boxes should still appear. Can you see anything from my code as to what I could be doing incorrectly? Thanks!
Inside my function MainWindow::createGUI
QFrame *mainFrame = new QFrame( this );
QVBoxLayout *mainLayout = new QVBoxLayout( mainFrame );
QSplitter *mainSplitter = new QSplitter( Qt::Horizontal );
QFrame *constraintFrame = new QFrame( mainSplitter );
QVBoxLayout *constraintLayout = new QVBoxLayout( constraintFrame );
...
createBox1( );
createBox2( );
createBox3( );
createBox4( );
constraintLayout->addWidget( mpBox1 );
constraintLayout->addWidget( mpBox2 );
constraintLayout->addWidget( mpBox3 );
constraintLayout->addWidget( mpBox4 );
...
setCentralWidget( mainFrame );
bool MainWindow::createBox1( )
{
mpBox1 = new QGroupBox( tr( "Display Constraints" ) );
QGridLayout *layout1 = new QGridLayout( mpBox1 );
QLabel *collectorsLabel = new QLabel( tr( "Collectors" ), this );
QLabel *minLabel = new QLabal( tr( "Min1:" ), this );
QLabel *maxLabel = new QLabel( tr( "Max1:" ), this );
mCollectorsBox = new QComboBox( this );
mMinLineEdit = new QLineEdit( this );
mMaxLineEdit = new QLineEdit( this );
mCollectorsBox->insertItem( tr( "1" ) );
mCollectorsBox->insertItem( tr( "2" ) );
mCollectorsBox->insertItem( tr( "3" ) );
mCollectorsBox->insertItem( tr( "4" ) );
mCollectorsBox->insertItem( tr( "5" ) );
layout1->addMultiCellWidget( collectorsLabel, 0, 0, 0, 1 );
layout1->addMultiCellWidget( mCollectorsBox, 0, 0, 3, 3 );
layout1->addMultiCellWidget( minLabel, 1, 1, 0, 0, Qt::AlignCenter );
layout1->addMultiCellWidget( mMinLineEdit, 1, 1, 1, 3 );
layout1->addMultiCellWidget( maxLabel, 2, 2, 0, 0, Qt::AlignCenter );
layout1->addMultiCellWidget( mMaxLineEdit, 2, 2, 1, 3 );
return true;
}
bool MainWindow::createBox4( )
{
mpBox4 = new QGroupBox( tr( "Section Constraints" ) );
QGridLayout *layout4 = new QGridLayout( mpBox4 );
QLabel *minLabel = new QLabal( tr( "Min2:" ), this );
QLabel *maxLabel = new QLabel( tr( "Max2:" ), this );
mMinSectionLineEdit = new QLineEdit( this );
mMaxSectionLineEdit = new QLineEdit( this );
layout1->addMultiCellWidget( minLabel, 0, 0, 0, 0, Qt::AlignCenter );
layout1->addMultiCellWidget( mMinSectionLineEdit, 0, 0, 1, 1 );
layout1->addMultiCellWidget( maxLabel, 1, 1, 0, 0, Qt::AlignCenter );
layout1->addMultiCellWidget( mMaxSectionLineEdit, 1, 1, 1, 1 );
return true;
}
Any of the members that begin with "mp" are member-pointers of my class and any object that begins with "m" is a class member with the exception of minLabal and maxLabel. When I run the program the main part of my window looks like:
collectorsLabel mCollectorsBox
Min2: mMinSectionLineEdit
Min1: mMinLineEdit
Max2: mMaxSectionLineEdit
Max1: mMaxLineEdit
My plan is for it to look like:
GroupBox1
collectorsLabel mCollectorsBox
Min1: mMinLineEdit
Max1: mMaxLineEdit
GroupBox2
GroupBox3
GroupBox4
Min2: mMinSectionLineEdit
Max2: mMaxSectionLineEdit
Like I said GroupBox2 and GroupBox3 are empty when I first load the program but the boxes should still appear. Can you see anything from my code as to what I could be doing incorrectly? Thanks!