Important: Please read the Qt Code of Conduct -

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

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

    Dialog::Dialog(QWidget *parent) :
    ui(new Ui::Dialog)

    QGraphicsDropShadowEffect *e = new QGraphicsDropShadowEffect(this);


    delete ui;


    frame and his children have a shadow
    but,when I add this:

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


  • 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":

    hope it helps.

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

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

  • 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

Log in to reply