I solved this problem.
{
Q_OBJECT
public:
explicit Dialog1
(QWidget *parent
= nullptr
);
~Dialog1();
private:
Ui::Dialog1 *ui;
protected:
};
class Dialog1 : public QDialog
{
Q_OBJECT
public:
explicit Dialog1(QWidget *parent = nullptr);
~Dialog1();
private:
Ui::Dialog1 *ui;
protected:
bool event(QEvent*e);
};
To copy to clipboard, switch view to plain text mode
Dialog1
::Dialog1(QWidget *parent
) : QDialog(parent
),ui
(new Ui
::Dialog1) {
ui->setupUi(this);
setWindowFlags(Qt::Window);
setWindowOpacity(0);
}
{
if(e
->type
()==QEvent::WindowActivate) {
QTimer::singleShot(0,
NULL,
[this](){this
->setWindowOpacity
(1);
});
return true;
}
{
setWindowOpacity(0);
return true;
}
}
Dialog1::Dialog1(QWidget *parent) :
QDialog(parent),ui(new Ui::Dialog1)
{
ui->setupUi(this);
setWindowFlags(Qt::Window);
setWindowOpacity(0);
}
bool Dialog1::event(QEvent*e)
{
if(e->type()==QEvent::WindowActivate)
{
QTimer::singleShot(0,NULL,[this](){this->setWindowOpacity(1);});
return true;
}
if(e->type()==QEvent::Hide)
{
setWindowOpacity(0);
return true;
}
return QDialog::event(e);
}
To copy to clipboard, switch view to plain text mode
This is not a Qt problem, this is a Windows problem. I looked at my WPF and Windows Forms projects and saw that they have this problem. You can also see it by running Windows Explorer or Windows Task Manager. Another question is whether this is considered a problem. I think so, Yes. This flickering hits my eyes
Bookmarks