Yeah, as soon as you apply even an empty stylesheet, most of the native look is gone. Tis pity. :(
A custom layout, or custom toolbutton is what I would do. Possibly reshuffle the widgets so one ends up ontop of the other, they are likely in a regular QVBoxLayout internally. On 15 March 2016 at 21:39, Justin Israel <[email protected]> wrote: > Hey Arvid, > > You could do it with StyleSheets but the pain in the butt is that once you > start defining some of the button style stuff, you have to define all of > the look. i.e. the gradients and borders, etc.. > > Another way that you could solve this is to just do a custom layout inside > of the button: > > b = QtGui.QToolButton() > l = QtGui.QVBoxLayout(b) > text = QtGui.QLabel("Text") > pic = QtGui.QLabel() > pic.setPixmap('path_to_icon.png') > pic.setScaledContents(True) > l.addWidget(text, 0, QtCore.Qt.AlignCenter) > l.addWidget(pic, 0, QtCore.Qt.AlignCenter) > b.setMinimumSize(100, 60) > > > --Justin > > > On Wed, Mar 16, 2016 at 8:41 AM Arvid Schneider <[email protected]> > wrote: > >> Hi there, >> been searching the forums quite a bit..but couldnt find something >> reasonable. >> I have a QToolButton and an icon. I dont want to bake the text into the >> icon image, I d rather have a text using btn.setText("Text"). >> The problem the text is set right underneath the icon which I dont want >> in my case. >> It should be on top of the icon. Is there any way to do that? >> I guess with a custom QToolButton..could someone help me out there? >> >> >> btn = QtGui.QToolButton() >> btn.setText("Text") >> icon = QtGui.QIcon() >> icon.addPixmap(os.path.join('path_to_icon.png', QtGui.QIcon.Normal, >> QtGui.QIcon.On) >> btn.setIcon(icon) >> >> ideally: >> icon.setToolButtonStyle(QtCore.Qt.ToolButtonText*OnTop*Icon >> >> >> >> Is there a way to offset the text using style sheet? >> Any help is appreciated >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Python Programming for Autodesk Maya" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/python_inside_maya/1b3c3979-741f-476d-99ea-da96b656819b%40googlegroups.com >> <https://groups.google.com/d/msgid/python_inside_maya/1b3c3979-741f-476d-99ea-da96b656819b%40googlegroups.com?utm_medium=email&utm_source=footer> >> . >> For more options, visit https://groups.google.com/d/optout. >> > -- > You received this message because you are subscribed to the Google Groups > "Python Programming for Autodesk Maya" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2SdNnKLwU1oJax%3DADFZu%3Dimxx2CNraJjJsdXGvmqA90g%40mail.gmail.com > <https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA2SdNnKLwU1oJax%3DADFZu%3Dimxx2CNraJjJsdXGvmqA90g%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > For more options, visit https://groups.google.com/d/optout. > -- *Marcus Ottosson* [email protected] -- You received this message because you are subscribed to the Google Groups "Python Programming for Autodesk Maya" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/python_inside_maya/CAFRtmOAqE_Q3wXxwKWXg4-PD6y-cwNySg6Q45Tva5OUypTPEKw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
