From kde-look Mon Apr 24 14:38:54 2000 From: Thomas Zander Date: Mon, 24 Apr 2000 14:38:54 +0000 To: kde-look Subject: Help needed with a QGroupBox X-MARC-Message: https://marc.info/?l=kde-look&m=95658720707252 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--ELM956587134-26931-0_" --ELM956587134-26931-0_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Hi, I've been hacking at the control center [file assiciations] module. Mostly the layout. Since the dialog did not resize when the window did. I put everything in a QGridLayout, and wanted to put the Iconbutton inside a QGroupBox, creating a total hierarchy as the following: QGridLayout +- QGroupBox +- QHBoxLayout +- KIconLoaderButton The QHBoxLayout is used because something has to go into the QGroupBox... This works just fine: QHBoxLayout *hBox = new QHBoxLayout(this,KDialog::marginHint(), KDialog::spacingHint()); lay->addLayout(hBox,1,3); iconButton = new KIconLoaderButton(this); iconButton->setIconType(KIcon::Desktop, KIcon::MimeType); connect(iconButton, SIGNAL(iconChanged(QString)), SLOT(updateIcon(QString))); iconButton->setFixedSize(50, 50); hBox->addWidget(iconButton,AlignLeft); While this code puts my Iconbutton totaly on the wrong spot: (about centered in the whole dialog) gb = new QGroupBox(i18n("Icon"), this); QHBoxLayout *hBox = new QHBoxLayout(gb,KDialog::marginHint(), KDialog::spacingHint()); lay->addWidget(gb,1,3); //[same 2nd part as above] iconButton = new KIconLoaderButton(this); iconButton->setIconType(KIcon::Desktop, KIcon::MimeType); connect(iconButton, SIGNAL(iconChanged(QString)), SLOT(updateIcon(QString))); iconButton->setFixedSize(50, 50); hBox->addWidget(iconButton,AlignLeft); Could someone help me out here. As an attachment you'll find the patch with the code.. (patch -0 addLayout(topLayout); - QGridLayout *leftLayout = new QGridLayout(2, 2); - topLayout->addLayout(leftLayout, 2); + QString wtstr; //help string + QGroupBox *gb; // group boxes + QGridLayout *lay = new QGridLayout(this,8,5); + lay->addRowSpacing(0,10); + lay->addRowSpacing(2,10); + lay->addRowSpacing(4,10); + lay->addRowSpacing(7,10); + lay->addColSpacing(0,10); + lay->addColSpacing(2,10); + lay->addColSpacing(4,10); + + lay->setRowStretch(0,0); + lay->setRowStretch(1,0); // ROW_ICON + lay->setRowStretch(2,0); + lay->setRowStretch(3,5); // ROW_FILE_PATTERNS + lay->setRowStretch(4,0); + lay->setRowStretch(5,5); // ROW_APPLICATION.. + lay->setRowStretch(6,10); + lay->setRowStretch(7,0); + + lay->setColStretch(0,0); + lay->setColStretch(1,1); + lay->setColStretch(2,0); + lay->setColStretch(3,1); + lay->setColStretch(4,0); + + QGridLayout *left = new QGridLayout(this,2,1); + left->setRowStretch(0,1); + left->setRowStretch(1,0); // ROW BUTTONS + left->setColStretch(0,1); + left->setColStretch(1,1); + + lay->addMultiCell(left,1,6,1,1); typesLV = new QListView(this); typesLV->setRootIsDecorated(true); typesLV->addColumn(i18n("Known Types")); - leftLayout->addMultiCellWidget(typesLV, 0, 0, 0, 1); + left->addMultiCellWidget(typesLV, 0,0,0,1); connect(typesLV, SIGNAL(selectionChanged(QListViewItem *)), this, SLOT(updateDisplay(QListViewItem *))); @@ -55,35 +79,37 @@ QPushButton *addTypeB = new QPushButton(i18n("&Add..."), this); connect(addTypeB, SIGNAL(clicked()), this, SLOT(addType())); - leftLayout->addWidget(addTypeB, 1, 0); + left->addWidget(addTypeB, 1,0); QWhatsThis::add( addTypeB, i18n("Click here to add a new file type.") ); QPushButton *removeTypeB = new QPushButton(i18n("&Remove"), this); connect(removeTypeB, SIGNAL(clicked()), this, SLOT(removeType())); - leftLayout->addWidget(removeTypeB, 1, 1); + left->addWidget(removeTypeB, 1, 1); QWhatsThis::add( removeTypeB, i18n("Removes the selected file type.") ); - QVBoxLayout *rightLayout = new QVBoxLayout(); - topLayout->addLayout(rightLayout, 3); - - QHBoxLayout *hBox = new QHBoxLayout(); - rightLayout->addLayout(hBox); + // This should work, but places my iconButton centered in the whole dialog.. + gb = new QGroupBox(i18n("Icon"), this); + QHBoxLayout *hBox = new QHBoxLayout(gb,KDialog::marginHint(), KDialog::spacingHint()); + lay->addWidget(gb,1,3); +/* + //This works like a charm: + QHBoxLayout *hBox = new QHBoxLayout(this,KDialog::marginHint(), KDialog::spacingHint()); + lay->addLayout(hBox,1,3); */ iconButton = new KIconLoaderButton(this); iconButton->setIconType(KIcon::Desktop, KIcon::MimeType); connect(iconButton, SIGNAL(iconChanged(QString)), SLOT(updateIcon(QString))); - iconButton->setFixedSize(50, 50); - hBox->addWidget(iconButton); + hBox->addWidget(iconButton,AlignLeft); QWhatsThis::add( iconButton, i18n("This button displays the icon associated" " with the selected file type. Click on it to chose a new icon.") ); - QGroupBox *gb = new QGroupBox(i18n("File Patterns"), this); - hBox->addWidget(gb); + gb = new QGroupBox(i18n("File Patterns"), this); + lay->addWidget(gb,3,3); QGridLayout *grid = new QGridLayout(gb, 3, 2, KDialog::marginHint(), KDialog::spacingHint()); @@ -115,7 +141,7 @@ QWhatsThis::add( removeExtButton, i18n("Remove the selected file pattern.") ); gb = new QGroupBox(i18n("Description"), this); - rightLayout->addWidget(gb); + lay->addWidget(gb,5,3); gb->setColumnLayout(1, Qt::Horizontal); description = new KLineEdit(gb); @@ -129,7 +155,7 @@ QWhatsThis::add( description, wtstr ); gb = new QGroupBox(i18n("Application Preference Order"), this); - rightLayout->addWidget(gb); + lay->addWidget(gb,5,3); grid = new QGridLayout(gb, 5, 2, KDialog::marginHint(), KDialog::spacingHint()); @@ -170,7 +196,8 @@ QWhatsThis::add( servNewButton, i18n( "Add a new application for this file type." ) ); - wrapper->addStretch(1); + left->activate(); + lay->activate(); init(); } --ELM956587134-26931-0_--