Setting text alignment of a QToolButton



  • Hello Qt devs!

    I cannot figure out how to left align my text on a QToolButton.

    Can you help me out?

    Thank you for your time!



  • Hi,

    I also tried the same with stylesheets by setting the "text-align: left;" property but it didnt work out.
    One interesting thing is that if we add an image to the toolButton then the text is aligned to the left.
    So for the time being you can add a tranparent image to your resources/toolButton and write

    @ui->toolButton->setToolButtonStyle(Qt::ToolButtonTextBesideIcon);@



  • Well the thing is that I already have added a icon to the QToolButton, and the text is still centred.
    Also, my text is set to be under:
    @toolButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);@
    I guess I have to have short button texts then...

    Thank you for your time!


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.