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. SetStyleSheet to QPushButton - box-shadow
Forum Updated to NodeBB v4.3 + New Features

SetStyleSheet to QPushButton - box-shadow

Scheduled Pinned Locked Moved General and Desktop
8 Posts 3 Posters 20.6k 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.
  • N Offline
    N Offline
    never_ever
    wrote on last edited by
    #1

    Hi,
    I have a question. Is there a possibility to set shadoww to the pushbutton?

    Now, I have:

    @
    button->setStyleSheet(QString::fromUtf8("QPushButton{"
    "border-style:solid;"
    "border-width: 2px;"
    "border-color: #999999;"
    "border-radius: 10px;"
    "background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,"
    "stop: 0 #CCCCCC, stop: 1 #AAAAAA);}";
    @

    Now I want to set box-shadow
    "link to example shadow":http://www.webmonkey.com/wp-content/uploads/2011/05/box-shadowdiff.jpg
    and I tried to set it:

    @
    "box-shadow: 10px 10px 5px rgba(182, 191, 193, 0.5);"
    @

    But there is no effect. Is it possible to set the shadow? Or I do sth wrong?

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      Hiii.

      You can use QFrame with QPushbutton and can get desired shadow effects.
      Set the following properties:-
      1)frameShape - Panel
      2)frameShadow - Raised
      3)lineWidth - 5
      4)midelineWidth - 2

      Be Cute

      1 Reply Last reply
      0
      • N Offline
        N Offline
        never_ever
        wrote on last edited by
        #3

        But I also change shape of button and other properties, so I have to use setStyleSheet (I think so, if I am wrong, please correct me).

        1 Reply Last reply
        0
        • C Offline
          C Offline
          clochydd
          wrote on last edited by
          #4

          Only an idea:
          Perhaps you may succeed with border-style "see: ":http://www.w3.org/TR/css3-background/#border-style
          Haven't tried it yet but it seems flexible enough to paint the shadow, too (groove && / || ridge).

          1 Reply Last reply
          0
          • N Offline
            N Offline
            never_ever
            wrote on last edited by
            #5

            Yes, I thought about it, but I have to create couple of styles of buttons, and one of option was to use border-style:outset/inset, second option was to set border width, and now I want to add some shadow in third style.

            1 Reply Last reply
            0
            • C Offline
              C Offline
              clochydd
              wrote on last edited by
              #6

              You may even mix the styles for top, bottom, right & left lines with border-top-style etc.

              1 Reply Last reply
              0
              • N Offline
                N Offline
                never_ever
                wrote on last edited by
                #7

                Ok, I will try, thanks

                1 Reply Last reply
                0
                • IamSumitI Offline
                  IamSumitI Offline
                  IamSumit
                  wrote on last edited by
                  #8

                  Try this..

                  QWidget vpcWidget = new QWidget();

                  QPushButton *pBtn = new QPushButton();

                  pBtn->setParent(vpcWidget);

                  QGraphicsDropShadowEffect* effect = new QGraphicsDropShadowEffect();

                  effect->setBlurRadius(1); //Adjust accordingly

                  effect->setOffset(3,3); //Adjust accordingly

                  pBtn->setGraphicsEffect(effect);

                  vpcWidget->show();

                  Hope it helps

                  Be Cute

                  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