[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) :
    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



  • 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.



  • 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;
    w.setWindowOpacity(0.7);
    works on windows seven but not on winndows xp. maybe it is not thee same behavior with your code.
    regards



  • 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
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.