why the text of the qpushbutton could not be set text-align:center?
-
I added a pushbutton menu on the push button.and set the style like this.
QPushButton{ text-align:center;} QPushButton::menu-indicator{ image:none;}
even though I couldnt see the menu-indicator, the text of the pushbutton still is on the left side.I dont know why.Is it related to the
subcontrol-origin:margin; subcontrol-position:bottom right; margin-top:5px;
something else?
-
I added a pushbutton menu on the push button.and set the style like this.
QPushButton{ text-align:center;} QPushButton::menu-indicator{ image:none;}
even though I couldnt see the menu-indicator, the text of the pushbutton still is on the left side.I dont know why.Is it related to the
subcontrol-origin:margin; subcontrol-position:bottom right; margin-top:5px;
something else?
@nicker-player
Unfortunately, the text alignment of aQPushButton
isn't implemented (yet). -
@nicker-player
Unfortunately, the text alignment of aQPushButton
isn't implemented (yet).@Axel-Spoerl
Interesting. Per https://doc.qt.io/archives/qt-4.8/stylesheet-reference.html#text-align-prop it claims to have been supported for aQPushButton
since at least Qt 4.8, so I wonder when "yet" will be... ;-) -
@Axel-Spoerl
Interesting. Per https://doc.qt.io/archives/qt-4.8/stylesheet-reference.html#text-align-prop it claims to have been supported for aQPushButton
since at least Qt 4.8, so I wonder when "yet" will be... ;-)@JonB
I actually wanted to fix this a while ago, and even started writing a patch. But I got stuck in complexity and moved on to other tasks in the absence of a strong use case… -
@JonB
I actually wanted to fix this a while ago, and even started writing a patch. But I got stuck in complexity and moved on to other tasks in the absence of a strong use case…@Axel-Spoerl :)
-
@nicker-player
Unfortunately, the text alignment of aQPushButton
isn't implemented (yet).@Axel-Spoerl
So how could I put the text on the center position of the pushbutton object.With using the setFont method? -
@Axel-Spoerl
So how could I put the text on the center position of the pushbutton object.With using the setFont method?The default behaviour of QPushbutton is to centre the text.
Does the presence of a menu indicator force left alignment?
Why you would want to make a menu pushbutton and then hide any indication that a menu is present is a bit too "modern UI" for me.
-
@Axel-Spoerl
So how could I put the text on the center position of the pushbutton object.With using the setFont method?@nicker-player
As @ChrisW67 says, since the default ofQPushButton
is to center text it is not clear what your issue is exactly. Do you require adjustment by stylesheet? If not you can control the placement or hide the menu indicator more directly via code?