QPushButton Text Position



  • 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



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



  • 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



  • 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?



  • 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


Log in to reply
 

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