[Qt-interest] QDialog + Qt::FramelessWindowHint = void?
David Ching
dc at remove-this.dcsoft.com
Mon Mar 1 15:23:21 CET 2010
"Ulf-Alexander v. Ceumern-Lindenstjerna" <ceumern at vrmagic.com> wrote in
message news:1C5B9B48EC79514FB4F4A7884ACFCB9FE0DCB4 at vrmserver1.vrm.local...
> Hi List!
>
> I want to create my own QDialog, doing some custom painting. For that I
> need to hide the default windows decoration.
>
> However, when I call setWindowFlags(Qt::FramelessWindowHint); my dialog
> ceases to show at all.
>
> Code:
>
> class EsogDialog : public QDialog
> {
> Q_OBJECT
>
> typedef QDialog base_class_type;
> public:
> EsogDialog(QWidget *parent);
> ~EsogDialog();
>
> protected:
> virtual void paintEvent( QPaintEvent * event );
> virtual void showEvent( QShowEvent * event );
>
> private:
>
> };
>
> EsogDialog::EsogDialog(QWidget *parent)
> : base_class_type(parent)
> {
> setAttribute(Qt::WA_TranslucentBackground);
> setWindowFlags(Qt::FramelessWindowHint);
>
> // create full screen widget in background using parent
> QDialogButtonBox *buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok
> | QDialogButtonBox::Cancel);
>
> QVBoxLayout *l = new QVBoxLayout;
> l->addWidget(new QLabel("Some Text."));
> l->addWidget(buttonBox);
> setLayout(l);
>
> connect(buttonBox, SIGNAL(accepted()), this, SLOT(accept()));
> connect(buttonBox, SIGNAL(rejected()), this, SLOT(reject()));
> }
>
> Calling code:
>
> EsogDialog
> d(static_cast<QWidget*>(EsogEventFilterSingleton::getrSingleton().parent()));
> int ret = d.exec();
>
> otherCode(); // <-- never reached when
> setWindowFlags(Qt::FramelessWindowHint); is active
>
On Mac, I saw the default Qt::Dialog style caused some weirdness (window was
always on top), replacing with Qt::Window fixed it. Also, try setting these
style bits in the ctor call to the parent (I think it's the second
parameter, after "parent"), not in the ctor body.
-- David
More information about the Qt-interest-old
mailing list