I am trying to build a programmaticaly (with Qt 4.6) window containing the QPushButton series, all packed together. It should look like this (I call the toolbar):
Toolbar image http://img99.imageshack.us/img99/9853/examplezk.png
So, I created a Toolbox class derived from QWidget, which has the following constructor:
Toolbox::Toolbox (void) : QWidget (0, Qt::Tool) { setWindowTitle (tr ("Toolbox")); QGridLayout *group = new QGridLayout (this); group->setSpacing (0); group->setContentsMargins (0, 0, 0, 0); group->setSizeConstraint (QLayout::SetFixedSize); setLayout (group); unsigned k = 0; QPushButton *buttons = new QPushButton[6]; for (unsigned i = 0; i < 3; i++) for (unsigned j = 0; j < 2; j++) { buttons[k].setIcon (QIcon ("test.png")); buttons[k].setIconSize (QSize (32, 32)); buttons[k].setContentsMargins (0, 0, 0, 0); buttons[k].setCheckable (true); buttons[k].setAutoExclusive (true); group->addWidget (&buttons[k], i, j); k++; } buttons[1].setChecked (true);
Somehow this does not work, and my buttons do not pack together:
result http://img9.imageshack.us/img9/774/resultr.png
I will not be able to remove this vertical span (and the fields surrounding the entire array). Any help is appreciated.
qt macos
F'x
source share