Qt5 cann't display QWidget in Windows7



  • I use Qt5 to make a application.

    @Mainwindow::Mainwindow(QWidget parent) :
    QWidget (parent),
    ui(new Ui::Mainwindow)
    {
    setWindowFlags(Qt::FramelessWindowHint);
    setAttribute(Qt::WA_TranslucentBackground,true);
    QGraphicsDropShadowEffect
    eff = new QGraphicsDropShadowEffect(this);
    eff->setOffset(0);
    eff->setBlurRadius(4);
    eff->setColor(QColor(0,0,0,255*0.9);
    this->setGraphicsEffect(eff);
    ui->setupUi(this);
    show();
    }@

    It is not display in windows 7 except I let it minimize and show it again, it will display normal, but it works fine in windows XP.
    And when I use Qt4.8.5 , it worked fine both windows 7 and XP.

    How could I correct it?

    I do some work according to the google search to try, but has no effect.

    @setParent(0); // Create TopLevel-Widget
    setAttribute(Qt::WA_NoSystemBackground, true);
    setAttribute(Qt::WA_TranslucentBackground, true);
    setAttribute(Qt::WA_PaintOnScreen);@



  • A question about this:
    @
    setAttribute(Qt::WA_PaintOnScreen);
    @

    return "QWidget::paintEngine: Should no longer be called"?

    Qt::WA_PaintOnScreen requires paintEvent

    In .h file:
    @protected:
    virtual void paintEvent(QPaintEvent* evt);@

    In .cpp file:
    @void Mainwindow::paintEvent(QPaintEvent* evt)
    {
    ...
    }@

    Probably adding paintEvent will work.


Log in to reply
 

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