[Qt-interest] QPushButton width problems / layout issues
Kustaa Nyholm
Kustaa.Nyholm at planmeca.com
Thu Jun 24 14:21:17 CEST 2010
> Have you tried using QSpacerItems in the layout?
Yes, here is the code I have:
QHBoxLayout *horizontalLayout;
QPushButton *pushButton;
QSpacerItem *horizontalSpacer;
QPushButton *pushButton_2;
horizontalLayout = new QHBoxLayout(this);
horizontalLayout->setObjectName(QString::fromUtf8("horizontalLayout"));
pushButton = new QPushButton("A", this);
pushButton->setObjectName(QString::fromUtf8("pushButton"));
horizontalLayout->addWidget(pushButton);
horizontalSpacer = new QSpacerItem(40, 20, QSizePolicy::Expanding,
QSizePolicy::Minimum);
horizontalLayout->addItem(horizontalSpacer);
pushButton_2 = new QPushButton("LONG", this);
pushButton_2->setObjectName(QString::fromUtf8("pushButton_2"));
horizontalLayout->addWidget(pushButton_2);
This code was generated by QtDesigner and the Designer preview shows it
correctly ie both buttons take the minimal space required to display
the text properly and the spacer occopies the rest.
However in my code both buttons have the same size. If I add more text to
the LONG button then that grows .
I'm so confused, been trying to get this to work, on and off, for three
days...
br Kusti
More information about the Qt-interest-old
mailing list