[PyQt] Problems with stylesheets.

Hans-Peter Jansen hpj at urpla.net
Mon Dec 3 21:15:40 GMT 2007


Am Freitag, 30. November 2007 schrieb Gustavo A. Díaz:
> Hi guys.
>
> I have a weird problem when i want to style my app, but specially with
> QPushButton and QScrollBar.
>
> I have this for QPushButton:
>
> self.setStyleSheet (" \
>                 QPushButton {background-image:
> url(:/Styles/styles/oc_buttonBg.png); color: white; font: bold; \
>                 border-style: inset; background-repeat: no repeat;
> background-position: center;} \
>                 QPushButton:hover {background-image:
> url(:/Styles/styles/oc_buttonBg_hover.png); \
>                 border-style: inset; background-repeat: no repeat;
> background-position: center;} \
>                 QPushButton:pressed {background-image:
> url(:/Styles/styles/oc_buttonBg_pressed.png);\
>                 border-style: inset; background-repeat: no repeat;
> background-position: center;}")
>
> And for QScrollBar:
>
> self.setStyleSheet ("QScrollBar:vertical { \
>                       background-image:
> url(:/Styles/styles/scrollbar_bg.png); \
>                       width: 15px; \
>                       margin: 15px 0 15px 0;} \
>                       QScrollBar::handle:vertical { \
>                       background-image:
> url(:/Styles/styles/scrollbar_body.png); \
>                       min-height: 15px;} \
>                 QScrollBar::add-line:vertical { \
>                       border: 0px; \
>                       background-image:
> url(:/Styles/styles/scrollbar_downArrow_Bg.png); \
>                       height: 15px; \
>                       subcontrol-position: bottom; \
>                       subcontrol-origin: margin;} \
>                 QScrollBar::sub-line:vertical { \
>                       border: 0px; \
>                       background-image:
> url(:/Styles/styles/scrollbar_upArrow_Bg.png); \
>                       height: 15px; \
>                       subcontrol-position: top; \
>                       subcontrol-origin: margin;} \
>                       QScrollBar::up-arrow:vertical { \
>                       background-image:
> url(:/Styles/styles/scrollbar_upArrow.png); \
>                 background-repeat: no repeat; \
>                 width: 15px; \
>                 height: 15px;} \
>                 QScrollBar::down-arrow:vertical { \
>                       background-image:
> url(:/Styles/styles/scrollbar_downArrow.png); \
>                 background-repeat: no repeat; \
>                 width: 15px; \
>                 height: 15px;} \
>                       QScrollBar::add-page:vertical,
> QScrollBar::sub-page:vertical { \
>                       background: none;}")
>
> Now, the buttons are not being styled if the scrollbar stylesheet
> exist... if i delete the scrollbar stylesheet.. buttons style are there.
>
> Now, if a use both but in the QPushButton i use directly the name of the
> Widget to style (lets say, self.firstButton.setStyleSheet....) the
> buttons shows the style but the scrollbar back to QT4 default look...
>
> What is going on?
>
> Thanks
>
> Cheers.... and hope someone to respond my post someday.... lately no one
> does it.... :(

  First: you're so deep entangled in styling your apps, that you've most 
probably lost most of your readers _here_. Most of us mainly try to get 
their work done in the most effective way (primary reason for using PyQt in 
the first place), where styling is a minor, if at all issue..

  Second: you don't provide a simple self contained example, that 
demonstrates your problem. 

  Advice: if you're capable enough (you should, IMHO), forget 2nd bullet, 
create the example directly in C++ and direct your request to 
qt-interest at trolltech.com - significant lower S/N ratio, but maybe you're 
lucky and convince some TT folk to care about your issues. 

Pete



More information about the PyQt mailing list