Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Setting text alignment of a QToolButton
QtWS25 Last Chance

Setting text alignment of a QToolButton

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 9.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maxmotor
    wrote on last edited by
    #1

    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!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      Sam
      wrote on last edited by
      #2

      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);@

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maxmotor
        wrote on last edited by
        #3

        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!

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved