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. QSS + style code
Forum Updated to NodeBB v4.3 + New Features

QSS + style code

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 5.1k 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.
  • R Offline
    R Offline
    Ruzik
    wrote on last edited by
    #1

    Hellow, i have some problem:
    I have this code:
    @ QPalette * p = new QPalette;
    p->setColor(QPalette::Background, QColor(colorNames[a]));
    w->setFixedHeight(15);
    w->setFixedWidth(15);
    w->setAutoFillBackground(true);
    w->setPalette(*p);@
    And this:
    @QWidget[isColorRectangle = "true"]
    {
    border: 2px solid #C4C4C3;
    }
    QWidget[isColorRectangle="true"]:hover
    {
    border-color: blue;
    }@
    Both the code work alone, but when they are together to work only QSS, proposal to make all the QSS does not fit
    But if i declare a widget in designer all worke as it should
    Advance many thanks for your help!

    1 Reply Last reply
    0
    • S Offline
      S Offline
      sigrid
      wrote on last edited by
      #2

      The documentation for "setPalette":http://doc.qt.nokia.com/latest/qwidget.html#palette-prop states that it should not be used together with stylesheets. You need to choose between setting the palette or using the stylesheet.

      1 Reply Last reply
      0
      • R Offline
        R Offline
        Ruzik
        wrote on last edited by
        #3

        Yes, but if the widget is done in the designer, then everything works correctly

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Ruzik
          wrote on last edited by
          #4

          Then, how i can set color of the border around the widget when it is under the cursor without QSS

          1 Reply Last reply
          0
          • S Offline
            S Offline
            sigrid
            wrote on last edited by
            #5

            When not using stylesheets, you can reimplement "event()":http://doc.qt.nokia.com/latest/qwidget.html#event for the widget and listen for "QEvent::HoverEnter ":http://doc.qt.nokia.com/latest/qevent.html#Type-enum and QEvent::HoverLeave events. When you get a QEvent::HoverEnter you can set a bool variable to true and when you get a QHoverLeave you can set the bool variable to false and make sure to call "update()":http://doc.qt.nokia.com/atest/qwidget.html#update or "repaint":http://doc.qt.nokia.com/latest/qwidget.html#repaint after having changed the value of the variable

            Then you can reimplement "paintEvent()":http://doc.qt.nokia.com/latest/qwidget.html#paintEvent for the widget to draw a border if the bool variable is set to true.

            Does this approach work for you?

            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