나는 programmaticaly (Qt 4.6 포함)에서 일련의 QPushButton
을 모두 포함하는 창을 함께 구성하려고합니다. 그것은 (나는 도구 상자를 호출하는)과 같이 보일 것입니다 :QGridLayout의 모든 공백 제거
toolbox image http://img99.imageshack.us/img99/9853/examplezk.png
그래서, 나는 다음과 같은 생성자이는 QWidget에서 파생 도구 상자 클래스 생성 : 어떻게 든
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);
을, 그것을 일을하고 결국하지 않습니다 내 버튼을 함께 포장하지 않습니다 :이했습니다 제거 관리 할 수 없습니다
result http://img9.imageshack.us/img9/774/resultr.png
수직 간격 (그리고 전체 배열을 둘러싼 여백). 어떤 도움도 환영합니다.
링크가 종료되었습니다. – Trilarion
작동 링크 : https://bugreports.qt.io/browse/QTBUG-2699 – Taran