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. QPushButton Text Position

QPushButton Text Position

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 5.2k Views 1 Watching
  • 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.
  • S Offline
    S Offline
    sos1
    wrote on last edited by
    #1

    Is it possible to change the text position for a QPushButton? I would like to place the text outside of the push button and below it, as shown in the attached screenshot. I would like to use the stylesheet.

    Regards,
    James

    https://www.dropbox.com/s/um430p2hnty42ej/Button3.jpg

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

      You can use a QToolButton instead and call setToolButtonStyle ( Qt::ToolButtonTextUnderIcon).

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sos1
        wrote on last edited by
        #3

        OK.

        I set up a ToolButton and used the following code.
        @ui->toolButton->setIconSize(QSize(40, 40));
        ui->toolButton->setToolButtonStyle (Qt::ToolButtonTextUnderIcon);
        @
        The text remains in the center of the button. What am I doing wrong?

        Regards,
        James

        1 Reply Last reply
        0
        • S Offline
          S Offline
          steno
          wrote on last edited by
          #4

          I might have misunderstood at what you are trying to get at. Are you trying to have the text of the button outside of the visual bounds of the button?

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sos1
            wrote on last edited by
            #5

            Yes, I have a button with a diameter of 100 pixels and I want to place the text outside of that.
            After much searching it looks like the toolbutton ToolButtonTextUnderIcon will only move it outside of an icon of max 32x32 pixels.

            I have come to the conclusion that i have to subclass QPushButton and place the text where I want myself. Right now I am struggling with that, being new to Qt & C++.

            Regards,
            James

            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