Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. StyleSheet render correctly in desinger but not in working apps
Forum Updated to NodeBB v4.3 + New Features

StyleSheet render correctly in desinger but not in working apps

Scheduled Pinned Locked Moved General and Desktop
7 Posts 3 Posters 2.8k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Al79
    wrote on last edited by
    #1

    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

    1 Reply Last reply
    0
    • A Offline
      A Offline
      Al79
      wrote on last edited by
      #2

      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?

      1 Reply Last reply
      0
      • B Offline
        B Offline
        b1gsnak3
        wrote on last edited by
        #3

        did u set the objects name to btnNext and btnPrev?

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

        1 Reply Last reply
        0
        • D Offline
          D Offline
          dvdk
          wrote on last edited by
          #4

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

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Al79
            wrote on last edited by
            #5

            @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.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              b1gsnak3
              wrote on last edited by
              #6

              My mistake

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Al79
                wrote on last edited by
                #7

                @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.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved