kroenecker
6th January 2006, 23:19
I'm trying to do the examples in the QT 3 tutorial titled "C++ GUI Programming with Qt 3." Please note that I am trying to do the examples without QT Designer.
In chapter 2 there is a more button which allows a user to extend an options menu. The button works, but when it is toggled off, the size of the dialog screen remains the same. Is there a way to have it dynamically shrink to its original size?
Here is the constructor for my class, which inherits from QDialog:
SortDialog::SortDialog(QWidget * parent, const char * name)
: QDialog(parent, name)
{
setCaption("Sort");
pGroup = new QGroupBox( 2, Qt::Horizontal, "&Primary Key", this);
pLabel1 = new QLabel("Column", pGroup);
pCombo1 = new QComboBox(pGroup);
pLabel2 = new QLabel("Order", pGroup);
pCombo2 = new QComboBox(pGroup);
sGroup = new QGroupBox( 2, Qt::Horizontal, "&Secondary Key", this);
sLabel1 = new QLabel("Column", sGroup);
sCombo1 = new QComboBox(sGroup);
sLabel2 = new QLabel("Order", sGroup);
sCombo2 = new QComboBox(sGroup);
tGroup = new QGroupBox( 2, Qt::Horizontal, "&Tertiary Key", this);
tLabel1 = new QLabel("Column", tGroup);
tCombo1 = new QComboBox(tGroup);
tLabel2 = new QLabel("Order", tGroup);
tCombo2 = new QComboBox(tGroup);
okButton = new QPushButton("&Ok", this);
cancelButton = new QPushButton("&Cancel", this);
moreButton = new QPushButton("&More", this);
moreButton->setToggleButton(TRUE);
connect(okButton, SIGNAL(clicked()),
this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()),
this, SLOT(reject()));
connect(moreButton, SIGNAL(toggled(bool)),
sGroup, SLOT(setShown(bool)));
connect(moreButton, SIGNAL(toggled(bool)),
tGroup, SLOT(setShown(bool)));
QVBoxLayout *vert1 = new QVBoxLayout;
QVBoxLayout *vert2 = new QVBoxLayout;
vert1->addWidget(pGroup);
vert1->addStretch(1);
vert1->addWidget(sGroup);
vert1->addWidget(tGroup);
vert2->addWidget(okButton);
vert2->addWidget(cancelButton);
vert2->addWidget(moreButton);
vert2->addStretch(1);
QHBoxLayout *main = new QHBoxLayout(this);
main->setMargin(10);
main->setSpacing(10);
main->addLayout(vert1);
main->addLayout(vert2);
sGroup->hide();
tGroup->hide();
setColumnRange('A', 'Z');
}
I guess that I could create my own slot that uses the boolean value and resets the size of the QDialog if toggle is false. In that case what member function will let me resize QDialog?
In chapter 2 there is a more button which allows a user to extend an options menu. The button works, but when it is toggled off, the size of the dialog screen remains the same. Is there a way to have it dynamically shrink to its original size?
Here is the constructor for my class, which inherits from QDialog:
SortDialog::SortDialog(QWidget * parent, const char * name)
: QDialog(parent, name)
{
setCaption("Sort");
pGroup = new QGroupBox( 2, Qt::Horizontal, "&Primary Key", this);
pLabel1 = new QLabel("Column", pGroup);
pCombo1 = new QComboBox(pGroup);
pLabel2 = new QLabel("Order", pGroup);
pCombo2 = new QComboBox(pGroup);
sGroup = new QGroupBox( 2, Qt::Horizontal, "&Secondary Key", this);
sLabel1 = new QLabel("Column", sGroup);
sCombo1 = new QComboBox(sGroup);
sLabel2 = new QLabel("Order", sGroup);
sCombo2 = new QComboBox(sGroup);
tGroup = new QGroupBox( 2, Qt::Horizontal, "&Tertiary Key", this);
tLabel1 = new QLabel("Column", tGroup);
tCombo1 = new QComboBox(tGroup);
tLabel2 = new QLabel("Order", tGroup);
tCombo2 = new QComboBox(tGroup);
okButton = new QPushButton("&Ok", this);
cancelButton = new QPushButton("&Cancel", this);
moreButton = new QPushButton("&More", this);
moreButton->setToggleButton(TRUE);
connect(okButton, SIGNAL(clicked()),
this, SLOT(accept()));
connect(cancelButton, SIGNAL(clicked()),
this, SLOT(reject()));
connect(moreButton, SIGNAL(toggled(bool)),
sGroup, SLOT(setShown(bool)));
connect(moreButton, SIGNAL(toggled(bool)),
tGroup, SLOT(setShown(bool)));
QVBoxLayout *vert1 = new QVBoxLayout;
QVBoxLayout *vert2 = new QVBoxLayout;
vert1->addWidget(pGroup);
vert1->addStretch(1);
vert1->addWidget(sGroup);
vert1->addWidget(tGroup);
vert2->addWidget(okButton);
vert2->addWidget(cancelButton);
vert2->addWidget(moreButton);
vert2->addStretch(1);
QHBoxLayout *main = new QHBoxLayout(this);
main->setMargin(10);
main->setSpacing(10);
main->addLayout(vert1);
main->addLayout(vert2);
sGroup->hide();
tGroup->hide();
setColumnRange('A', 'Z');
}
I guess that I could create my own slot that uses the boolean value and resets the size of the QDialog if toggle is false. In that case what member function will let me resize QDialog?