[PyQt] Problems with stylesheets.

Hans-Peter Jansen hpj at urpla.net
Mon Dec 3 23:24:31 GMT 2007


[CC'ed pyqt, since your answer also contains info's of public interest]

Am Montag, 3. Dezember 2007 schrieben Sie:
> Well PETE.. I don't agree with you as you don't with me... so... save
> your words and just direct me to the Qt forum/ML instead... Is that too
> hard to do? :)
> Styling could be a minor problem, yes, but i could post anyway too... I
> don't care what you think about if i style to much or not my apps., i am
> just asking for help... and most cause i just started to develop since
> august.
>
> I know that is a minor "problem", still i could post.... Just maybe this
> is not the place, but like i said below....
>
> Indeed... already solved with the help of Qt Folks... now i know that is
> a question more of Qt than PyQt ;)

Since you already grabbed some of our lifetime, how about a short message 
about how you solved your issue. This would amplify the public 'googable' 
knowledge of dusty PyQt corners, and is a great way to give back something 
to the community without much hassle for you.

> Next time, shoot anyone else with your bullets ;)

I didn't intended to appear rude, maybe it was just a bit more direct than 
usual. I definitely won't deter you from posting here, nor from programming 
with PyQt. I simply did a _IMHO_ realistic classification of your issue 
from reading this list, hmm, for about 6 years now.

> And for the second... I don't provide a example code? lol.. you  are
> blind then...

Please read carefully: I talked about a [minimal] self contained example. 
You seem to expect us to add the missing pieces to your code in order to 
help _you_? A bit more sense of reality wouldn't harm then.

> Last, i am starting as PyQt, not C++ (and I don't care to learn it). Or i
> would never post here.

I learned a lot C++ details from studying Qt's source, and peered with 
PyQt's docs and sip's, this helped me to solve a lot of PyQt problems in 
the past, and greatly improved the quality of my _PyQt_ apps, at least.

I'm going to shut up now.

Pete

>
> Cheers.
>
> 2007/12/3, Hans-Peter Jansen <hpj at urpla.net>:
> > 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
> >
> > _______________________________________________
> > PyQt mailing list    PyQt at riverbankcomputing.com
> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt





More information about the PyQt mailing list