Problem with SpinBox Alignment
-
Environment: Mac OS 10.9.5, Windows 7
Qt: 4.8I'm trying to use right-alignment in a QtSpinBox, but all I see is left-alignment. This happens in Mac and Windows.
If the spin box just has a number in it, the justification changes as you'd expect. But I'm using a suffix, and in that spin box, everything always looks left-justified.
But in Qt Designer (4.8.5), you do see a difference. For example, in Designer:
Left-justified
!http://feigenson.net/ForumUploads/Screen_Capture_2015-01-28_at_11.56.32_AM-left.png(Left justified in Qt Designer)!Right-justified
!http://feigenson.net/ForumUploads/Screen_Capture_2015-01-28_at_11.56.11_AM-right.png(Right justified in Qt Designer)!However, in the application, I see this:
Left-justified
!http://feigenson.net/ForumUploads/Screen_Capture_2015-01-28_at_12.01.35_PM-left.png(Left justified in application)!Right-justified
!http://feigenson.net/ForumUploads/Screen_Capture_2015-01-28_at_12.00.34_PM-right.png(Right justified in application)!I get the same result on Mac and Windows.
Here's the relevant segment from the .ui file:
@ <widget class="QSpinBox" name="rate_spinBox">
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
<property name="suffix">
<string> Megabits/s</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>10000</number>
</property>
<property name="singleStep">
<number>1</number>
</property>
<property name="value">
<number>100</number>
</property>
</widget>@Does this ring any bells with anyone...?
Thanks!
-Eric
-
Hmmmm.... I just tried to post a reply and it disappeared :(
Short summary: Not sure what you mean, how would you do that?
In the meantime, I tried this (using PyQt4):
@self.rate_spinBox.setAlignment(Qt.AlignRight)@where rate_spinBox is the name of the spin box in question. It had no effect.
-
I tried this on my Mac. I was able to get a right alignment with a spin box (I am using Qt 5.4.0 not 4.8.x).
Your example doesn't look like a standard style from Qt 4.8.x Maybe the problem is related to the style (QStyle) you are using? Something not implemented properly to handle a right aligned spin box?
-
Please, try set a different style using the command line when launching the application.
In this page,
http://qt-project.org/doc/qt-4.8/qapplication.html
You can find more information:
@All Qt programs automatically support the following command line options:
-style= style, sets the application GUI style. Possible values are motif, windows, and platinum. If you compiled Qt with additional styles or have additional styles as plugins these will be available to the -style command line option.
-style style, is the same as listed above.@
-
Hi Rondog, thanks for your reply...
[quote author="Rondog" date="1422589181"]I tried this on my Mac. I was able to get a right alignment with a spin box (I am using Qt 5.4.0 not 4.8.x).
Your example doesn't look like a standard style from Qt 4.8.x Maybe the problem is related to the style (QStyle) you are using? Something not implemented properly to handle a right aligned spin box?[/quote]
I'm not using any Qstyles. I'm going from Designer (which generates the UI file) which is driven by Python using PyQt4. Though it's occurred to me that it is right-justified, it's just hard to tell with the size of the field. I'll have to play with that.