Hello,
Here it is.
#ifndef DlgTest_h
#define DlgTest_h
#include <QtCore/QDebug>
#include <QtGui/QDialog>
#include <QtGui/QPalette>
#include <QtGui/QTextEdit>
#include <QtGui/QPushButton>
#include <QtGui/QGridLayout>
Q_OBJECT
public:
/**/ DlgTest
(quint32 num,
QWidget *p
=0, Qt
::WFlags f
=Qt
::FramelessWindowHint|Qt
::X11BypassWindowManagerHint) : QDialog(p, f
), _txt
(0), _num
(num
) { //setWindowFlags ();
if (_num>1)
setModal (true);
// Layout, button, and text box.
_txt
->setText
(QString::number(_num
));
grid->addWidget (_txt);
grid->addWidget (btn);
setLayout (grid);
// Upon clicking the button, launch another dialog.
connect(btn, SIGNAL(clicked()), this, SLOT(mainButtonClicked()));
};
protected slots:
void mainButtonClicked () {
DlgTest *dlg = new DlgTest(_num+1, this);
connect(dlg, SIGNAL(finished(int)), dlg, SLOT(deleteLater()));
dlg->show ();
qDebug() << dlg->geometry();
};
private:
quint32 _num;
};
#endif
#ifndef DlgTest_h
#define DlgTest_h
#include <QtCore/QDebug>
#include <QtGui/QDialog>
#include <QtGui/QPalette>
#include <QtGui/QTextEdit>
#include <QtGui/QPushButton>
#include <QtGui/QGridLayout>
class DlgTest : public QDialog {
Q_OBJECT
public:
/**/ DlgTest (quint32 num, QWidget *p=0, Qt::WFlags f=Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint)
: QDialog(p, f), _txt(0), _num(num) {
//setWindowFlags ();
if (_num>1)
setModal (true);
// Layout, button, and text box.
QGridLayout *grid = new QGridLayout(this);
QPushButton *btn = new QPushButton(this);
_txt = new QTextEdit(this);
_txt->setText (QString::number(_num));
grid->addWidget (_txt);
grid->addWidget (btn);
setLayout (grid);
// Upon clicking the button, launch another dialog.
connect(btn, SIGNAL(clicked()), this, SLOT(mainButtonClicked()));
};
protected slots:
void mainButtonClicked () {
DlgTest *dlg = new DlgTest(_num+1, this);
connect(dlg, SIGNAL(finished(int)), dlg, SLOT(deleteLater()));
dlg->show ();
qDebug() << dlg->geometry();
};
private:
QTextEdit *_txt;
quint32 _num;
};
#endif
To copy to clipboard, switch view to plain text mode
You will start the first instance of this dialog with this in your main():
dlg.show();
DlgTest dlg (1, (QWidget*)QApplication::desktop());
dlg.show();
To copy to clipboard, switch view to plain text mode
Now, you will try the code with the flags that are in the constructor. Each new dialog will be offsetted.
After testing with these flags, you will replace "Qt::FramelessWindowHint|Qt::X11BypassWindowManage rHint" by 0, and try again.
The behavior i get with this minimal example isn't even the same as the one i have in my app... The offset being negative, in my app it's positive.
And the "ESC" problem isn't even here, so i guess it's related to something else i do in my app... i'll try to dig further.
Sorry for the indentation... Visual studio doesn't seem to understand what soft tabs are on this computer.
[edit]
i found what to do to reproduce the ESC bug. Remove the flags from the constructor (Replace them by 0 by default). Then, put this in the constructor:
setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint);
setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint);
To copy to clipboard, switch view to plain text mode
i have tried:
setWindowFlags(windowFlags()|Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint);
setWindowFlags(windowFlags()|Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint);
To copy to clipboard, switch view to plain text mode
But the result is even different and unusable. So maybe i misunderstood the use of those flags?
[/edit]
Pierre.
Bookmarks