Hello,
Is it possible to style the QRadioButton (and maybe als the QCheckBox) so that the text can be on the left sight of the Indicator, or above it?
Thx for your help.
Hello,
Is it possible to style the QRadioButton (and maybe als the QCheckBox) so that the text can be on the left sight of the Indicator, or above it?
Thx for your help.
Yes, it is possible. One way which I could suggest right way is use QStyleSheet with somthing like this
Qt Code:
" width: 10px;\n" " spacing: -75px;\n" "}\n" "\n" "QCheckBox::indicator {\n" " subcontrol-origin: content;\n" " subcontrol-position: right top;\n" "}"));To copy to clipboard, switch view to plain text mode
" width: 10px;\n" - is required
" spacing: -75px;\n" - does the magic, and "-75" should be dynamically calculated based on your text rending length on screen, (may you build this into the custom QCheckBox class)
Thank you for the answer,
Unfortunately this does not work in my configuration (Qt 4.6 and SUSE 10.3).
The first issue - negative spacing shows the truncated text directly ON CheckBox (does no matter how many negative px is set), by the second issue the text disappears completely.
Maybe in the newer versions this will work correctly.
Added after 10 minutes:
p.s.
I hate these style sheets!
That's mixing of C++ with "something"!
Why there is no simply an according method for such operations?
Last edited by lotek; 16th June 2011 at 20:50.
Subclass QRadioButton, draw the indicator using QStyle, then draw the text where you need it using QPainter::drawText().
If you want the text on the left side and the icon on the right, you should be able to use:
radioButton->setLayoutDirection(Qt::RightToLeft);
Bookmarks