StyleSheet render correctly in desinger but not in working apps



  • Hi all,

    i wrote some StyleSheet lines to render two QPushButtons rounded:

    @QPushButton{
    background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #f6f7fa, stop: 1 #dadbde);
    border: 2px outset grey;
    border-style: solid;
    border-width:1px;
    border-radius:5px;
    border-color: black;
    max-width:10px;
    max-height:10px;
    min-width:10px;
    min-height:10px;
    }

    QPushButton:pressed{
    border-radius: 5px;
    border: 2px outset grey;
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0, #dadbde, stop: 1 #c5c6c9);
    max-width:10px;
    max-height:10px;
    min-width:10px;
    min-height:10px;
    }
    @

    as I'm using them into a designer's Form I can see the preview and it looks nice:

    !http://i.imgur.com/9SepJLs.png?1(designer preview)!

    but when I compile and run my app, QPushButtons look squared instead of rounded:

    !http://i.imgur.com/g9eHIsw.png?1(real buttons)!

    I tried to add into form class the stylesheet statements programmatically instead of using "change styleSheet" in designer, but nothing happens and I get the same squared buttons.

    After form creation I added this (FindForm) form to final Dialog promoting a QWidget that works as placeholder. And I can't change stylesheet from that point, as FindForm ui is a private variable.

    Where is my mistake?

    Thanks in advance for any help.
    Al



  • I found the point:

    i have some stylesheet statements that conflicts with those for rounded buttons:

    @
    QPushButton{
    border: 2px outset grey;
    border-radius: 10px;
    padding: 7px 7px 7px 7px;
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #f6f7fa, stop: 1 #dadbde);
    }

    QPushButton:pressed{
    border: 2px outset grey;
    border-radius: 10px;
    padding: 7px 7px 7px 7px;
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #dadbde, stop: 1 #c5c6c9);
    }

    QPushButton:disabled{
    background: lightgrey;
    }

    QPushButton#btnNext,QPushButton#btnPrev {
    background-color:qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #f6f7fa, stop: 1 #dadbde);
    border: 2px outset grey;
    border-style: solid;
    border-width:1px;
    border-radius:5px;
    border-color: black;
    max-width:10px;
    max-height:10px;
    min-width:10px;
    min-height:10px;
    }

    QPushButton:pressed#btnNext,QPushButton:pressed#btnPrev {
    border-radius: 5px;
    border: 2px outset grey;
    background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0, #dadbde, stop: 1 #c5c6c9);
    max-width:10px;
    max-height:10px;
    min-width:10px;
    min-height:10px;
    }
    @

    I tried to specify that rounded statements must be applied only to btnNext and btnPrev QPushButtons, but style engine use general directive too...

    Any ideas to solve?



  • did u set the objects name to btnNext and btnPrev?

    @btnNext->setObjectName("btnNext");
    btnPrev->setObjectName("btnPrev");@



  • Why don't you remove "border-radius: 10px;" from QPushButton and QPushButton:pressed blocks?



  • @b1gsnak3: yes i set up object names directly with desinger. The result is the same...

    @dvdk: because i have general buttons, where I need that radius is a bit bigger because buttons are bigger, and "next", "previous" buttons where i display only a small arrow. So border-radius i'd like it would smaller...If i try to use style statements for "next" and "prev" to all QPushButtons other buttons are too small to display a label in them.



  • My mistake



  • @b1gsnak3:

    maybe i didn't exposed my issue well. I have two kind of buttons:

    prev,next buttons,

    all other QPushButtons.

    QPushButton{blablabla} must have a bigger border-radius because i display a label (i.e. "Close", or something else...). While Prev and Next QPushButtons display only a small arrow, so i need to style them smaller...
    Surely my bad english doesn't help to understand each other...sorry.


Log in to reply
 

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