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]After setting the background color, can not display the object's shadow
Forum Updated to NodeBB v4.3 + New Features

[Solved]After setting the background color, can not display the object's shadow

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

    Hello All,
    I developed the following code:
    @#include "dialog.h"
    #include "ui_dialog.h"
    #include <QGraphicsDropShadowEffect>

    Dialog::Dialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::Dialog)
    {
    ui->setupUi(this);

    QGraphicsDropShadowEffect *e = new QGraphicsDropShadowEffect(this);
    e->setOffset(-5,5);
    e->setColor(QColor(19,29,31));
    e->setBlurRadius(8);
    ui->frame->setGraphicsEffect(e);
    

    }

    Dialog::~Dialog()
    {
    delete ui;
    }

    @

    frame and his children have a shadow
    but,when I add this:
    @ui->frame->setStyleSheet("background-color:rgb(123,31,22)");
    @

    The child object shadow is missing..
    I must set background use stylesheet,
    how can I do for this.

    Thanks

    1 Reply Last reply
    0
    • T Offline
      T Offline
      tilsitt
      wrote on last edited by
      #2

      Hi,

      when you use style sheet, you erase the whole default style sheet, so you have to define your shadow effect inside the style sheet, or to set background without style sheet (e.g. using the "palette":http://qt-project.org/doc/qt-4.8/qwidget.html#palette-prop).

      hope it helps.

      1 Reply Last reply
      0
      • L Offline
        L Offline
        landing kiss
        wrote on last edited by
        #3

        hi lacewu i know some do you develop on windows xp ?

        kobena

        1 Reply Last reply
        0
        • L Offline
          L Offline
          landing kiss
          wrote on last edited by
          #4

          if you develop on xp know that some function doesn't work on window xp for example :
          QWidget *w;
          w.setWindowOpacity(0.7);
          works on windows seven but not on winndows xp. maybe it is not thee same behavior with your code.
          regards

          kobena

          1 Reply Last reply
          0
          • L Offline
            L Offline
            lacewu
            wrote on last edited by
            #5

            thanks.
            I'm sorry I confirmed so late.
            my progrom is run in Ubuntu10.04,
            and set background using the palette,the effect is the same
            this solved like below:
            class A{
            frame = new QFrame;
            new B(frame);//object B`s parent is frame
            //set shadow
            }

            class B{
            //create buttons
            //set shadow
            }

            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