[Qt-interest] QPushButton width problems / layout issues
Ramesh
ramesh.bs at robosoftin.com
Thu Jun 24 10:48:15 CEST 2010
Can u send me the snapshot of how your button should look.
It will be good to analyze
-----Original Message-----
From: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] On Behalf Of Kustaa Nyholm
Sent: Thursday, June 24, 2010 1:23 PM
To: QT Interest List
Subject: Re: [Qt-interest] QPushButton width problems / layout issues
Thanks Ramesh for taking interest.
> You have two option,
> First:
> Set the horizontal size policy to proffered for a button which you want to
> keep fixed.
> Make horizontal size policy to expanding for the button to be expand.
>
> like this,
>
> QSizePolicy sizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
> pushButton_2->setSizePolicy(sizePolicy);
>
I tried your suggestion, and it does make button 'LONG' wider, but
button 'A' stays the same (which is too wide, previewing this in Designer
shows a much narrower button for 'A').
This is not what I need. What I want is that both buttons to take only the
minimum amount they require and let the spacer expand to fill the space.
And this is what I see in QtDesigner with identical code. As I explained I
created a similar layout that does what I want in Designer and copy/pasted
the code from there to my actual code and it does not work the
same as in Designer.
>
> Second:
> You can use setgeometry() to set the position of a button.
>
Well, I did not try this, but I have understood that if there is
a QLayout involved then setGeometry() cannot be used as the layout
will also call setGeometry() on the widgets. But regardless the
my point is that I do not want to create my own code to calculate
the widget sizes and then do a setGeometry() on the widgets, because
that is exactly what the QHBoxLayout is supposed to do. And it does,
if I use identical code in Designer, it is only in the context
of my application / other widgets that it fails.
So I really would like to understand what can affect how the
widgets are laid out. I've throw everything I can think of at
the layouts and widgets in question so now I'm thinking that
this is something (size polizy or anything) in one of the
other widgets in the hierarchy.
I've read through the QLayout.cpp but it is hard follow without
a debugger and so far I've not been able to set break points
with gdb on Mac OS X.
br Kusti
_______________________________________________
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