Results 1 to 8 of 8

Thread: QDialog behavior changes when Qt::FramelessWindowHint is applied to it.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #3
    Join Date
    Dec 2006
    Posts
    160
    Thanks
    33
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QDialog behavior changes when Qt::FramelessWindowHint is applied to it.

    Hello,

    Here it is.
    Qt Code:
    1. #ifndef DlgTest_h
    2. #define DlgTest_h
    3.  
    4. #include <QtCore/QDebug>
    5. #include <QtGui/QDialog>
    6. #include <QtGui/QPalette>
    7. #include <QtGui/QTextEdit>
    8. #include <QtGui/QPushButton>
    9. #include <QtGui/QGridLayout>
    10.  
    11. class DlgTest : public QDialog {
    12. Q_OBJECT
    13. public:
    14. /**/ DlgTest (quint32 num, QWidget *p=0, Qt::WFlags f=Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint)
    15. : QDialog(p, f), _txt(0), _num(num) {
    16. //setWindowFlags ();
    17. if (_num>1)
    18. setModal (true);
    19. // Layout, button, and text box.
    20. QGridLayout *grid = new QGridLayout(this);
    21. QPushButton *btn = new QPushButton(this);
    22. _txt = new QTextEdit(this);
    23. _txt->setText (QString::number(_num));
    24. grid->addWidget (_txt);
    25. grid->addWidget (btn);
    26. setLayout (grid);
    27. // Upon clicking the button, launch another dialog.
    28. connect(btn, SIGNAL(clicked()), this, SLOT(mainButtonClicked()));
    29. };
    30. protected slots:
    31. void mainButtonClicked () {
    32. DlgTest *dlg = new DlgTest(_num+1, this);
    33. connect(dlg, SIGNAL(finished(int)), dlg, SLOT(deleteLater()));
    34. dlg->show ();
    35. qDebug() << dlg->geometry();
    36. };
    37. private:
    38. QTextEdit *_txt;
    39. quint32 _num;
    40. };
    41.  
    42. #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():
    Qt Code:
    1. DlgTest dlg (1, (QWidget*)QApplication::desktop());
    2. 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:
    Qt Code:
    1. setWindowFlags(Qt::Dialog|Qt::FramelessWindowHint|Qt::X11BypassWindowManagerHint);
    To copy to clipboard, switch view to plain text mode 
    i have tried:
    Qt Code:
    1. 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.
    Last edited by hickscorp; 5th April 2012 at 11:29.

Similar Threads

  1. Curve Fitting Not Always Applied
    By Mannion in forum Qwt
    Replies: 3
    Last Post: 16th March 2011, 08:11
  2. KDE 3 style applied to Qt 4 programs
    By alecs1 in forum KDE Forum
    Replies: 4
    Last Post: 4th December 2008, 21:24
  3. setWindowFlags(Qt::FramelessWindowHint)
    By smarinr in forum Qt Programming
    Replies: 5
    Last Post: 30th April 2008, 20:12
  4. Confused QWidget and QDialog behavior
    By munna in forum Qt Programming
    Replies: 1
    Last Post: 9th December 2006, 12:14
  5. Qt::FramelessWindowHint
    By L.Marvell in forum Qt Programming
    Replies: 16
    Last Post: 6th May 2006, 16:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.