[Qt-interest] QPushButton width problems / layout issues
Ramesh
ramesh.bs at robosoftin.com
Thu Jun 24 15:47:38 CEST 2010
I don't think so, it should not create problems.
I have not tried very complex things, but most of the things worked for me.
Hey can you post the entire code generated by your UI designer header
file.i.e UI_....h file
-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of John McClurkin
Sent: Thursday, June 24, 2010 6:30 PM
To: qt-interest at trolltech.com
Subject: Re: [Qt-interest] QPushButton width problems / layout issues
Kustaa Nyholm wrote:
>> 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
>
You say that the Designer preview shows the buttons correctly but your
code does not. Does this mean that you are not using the Designer
generated .ui files in your application? Are you trying to do everything
in code? It has been a while since I went through this so I don't
remember the details, but I have had problems trying to duplicate
Designer generated code in my own code, so I use the .ui files generated
by Designer in my applications.
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest
-----------------------------------------------
Robosoft Technologies - Come home to Technology
Disclaimer: This email may contain confidential material. If you were not an intended recipient, please notify the sender and delete all copies. Emails to and from our network may be logged and monitored. This email and its attachments are scanned for virus by our scanners and are believed to be safe. However, no warranty is given that this email is free of malicious content or virus.
More information about the Qt-interest-old
mailing list