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. [Solved] Unknown property box-shadow styling with CSS
QtWS25 Last Chance

[Solved] Unknown property box-shadow styling with CSS

Scheduled Pinned Locked Moved General and Desktop
10 Posts 3 Posters 38.4k Views
  • 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.
  • T Offline
    T Offline
    Tarka85
    wrote on 11 Apr 2013, 19:09 last edited by
    #1

    Hi! I'm new in the forum and in Qt and I'm experimenting with CSS styles for a desktop app. I'm a Python developer so I'm using PySide.

    I was looking in the internet for a solution to my problem but I did not find it. The thing is that I can't add a shadow to a QLabel using this code:

    My Qt version is 4.8.3

    [code]
    QLabel {
    background: rgba(200,0,0);
    border: 0px solid blue;
    padding: 5px;
    border-radius: 5px;
    margin: 2px;
    box-shadow: 0px -3px 5px #a6a6a6;
    }
    [/code]

    ...and I get "Unknown property box-shadow".
    I tried also with -webkit-box-shadow.

    Well... this is all for know. Thanks and please excuse my english.

    1 Reply Last reply
    0
    • C Offline
      C Offline
      Chris Kawa
      Lifetime Qt Champion
      wrote on 11 Apr 2013, 19:27 last edited by
      #2

      Qt widgets support only a subset of CSS. The complete list of supported properties is "here":http://qt-project.org/doc/qt-4.8/stylesheet-reference.html#list-of-properties

      1 Reply Last reply
      0
      • T Offline
        T Offline
        Tarka85
        wrote on 11 Apr 2013, 23:38 last edited by
        #3

        Ok. Thank you Krzysztof!

        1 Reply Last reply
        0
        • B Offline
          B Offline
          b1gsnak3
          wrote on 12 Apr 2013, 06:57 last edited by
          #4

          For shadow you could use QGraphicsDropShadowEffect

          1 Reply Last reply
          0
          • C Offline
            C Offline
            Chris Kawa
            Lifetime Qt Champion
            wrote on 12 Apr 2013, 10:14 last edited by
            #5

            QGraphicsDropShadowEffect is only for the items in QGraphicsView, not for widgets (unless you put a widget in QGraphicsView, but that's another story).

            For simple shadows you might fake it by setting border in a CSS to a carefully crafted gradient, or subclass a QLabel, give it a little padding and draw the shadow in paintEvent.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              b1gsnak3
              wrote on 12 Apr 2013, 14:28 last edited by
              #6

              Kawa QWidget has a property "setGraphicsEffect":http://qt-project.org/doc/qt-4.8/qwidget.html#setGraphicsEffect where you can set your QGraphicsDropShadowEffect to any QWidget derived class :)

              1 Reply Last reply
              1
              • C Offline
                C Offline
                Chris Kawa
                Lifetime Qt Champion
                wrote on 12 Apr 2013, 14:41 last edited by
                #7

                Oh, I'm learning every day I guess :) Thanks for clearing this up.

                1 Reply Last reply
                0
                • B Offline
                  B Offline
                  b1gsnak3
                  wrote on 12 Apr 2013, 14:46 last edited by
                  #8

                  We all learn everyday :D np

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    Tarka85
                    wrote on 17 Apr 2013, 20:35 last edited by
                    #9

                    Thank you people!
                    The solution using qgradient color in the bordes with a CSS works well, but only with border-radius: 0px.

                    I will try with the QGraphicsDropShadowEffect too.

                    Thanks again and excuse my english.

                    1 Reply Last reply
                    0
                    • B Offline
                      B Offline
                      b1gsnak3
                      wrote on 18 Apr 2013, 06:23 last edited by
                      #10

                      Mark the post as solved please. Thank you

                      1 Reply Last reply
                      0

                      9/10

                      17 Apr 2013, 20:35

                      • Login

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