Results 1 to 8 of 8

Thread: How to make window semi modal

  1. #1
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default How to make window semi modal

    Hi,

    Consider the senario....

    There is a Push Button showWindow to Display a window on the Screen.
    When window is shown the PushButton Lable changes to HideWindow() and when i click on it
    the window is hidden again.

    Now this means the window need to be nonModal... and i can not call exec().

    but now window is gets hidden when i click on the parent (it is not closed just hides under the parent window - which is full screen).

    Is there a way to make this window 'always on top' and still it to be non modal?

    Please help.............

  2. #2
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to make window semi modal

    Is there no solution available....

    I just need a window to be always on top and be able to send inputs to parent dialog also.

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to make window semi modal

    Set the parent of the child dialog. Children are always on top of their parents, so clicking the parent will not cause it to be raised above the child.

  4. #4
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: How to make window semi modal

    Will setWindowFlags(Qt::WindowStaysOnTopHint) help you ?

  5. #5
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to make window semi modal

    setWindowFlags(Qt::WindowStaysOnTopHint) does not help...By using it the window is not even displayed..

    I have already passed the parent in the constructor while creating the widget.

    Problem not solved.... Help....

  6. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to make window semi modal

    You mean this doesn't work for you?

    Qt Code:
    1. #include <QtGui>
    2.  
    3. int main(int argc, char **argv){
    4. QApplication app(argc, argv);
    5. QDialog *dlg = new QDialog(&te);
    6. QVBoxLayout *l = new QVBoxLayout(dlg);
    7. l->addWidget(new QPushButton);
    8. te.show();
    9. // te.showFullScreen(); // works as well
    10. dlg->show();
    11. return app.exec();
    12. }
    To copy to clipboard, switch view to plain text mode 
    Do you see the child dialog when you click the parent?

  7. #7
    Join Date
    Jun 2008
    Posts
    89
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: How to make window semi modal

    This isn' t the code .
    I try to explain... I have a dialog derived from QGraphicsItem and QDialog. It has "Show" button. That button brings up another dialog and the button lable changes to "Hide".
    Now i need to close the newly opened dialog to be closed by clicking "Hide" button in parent dialog. Now the problem is, when i click any where on the application the newly opened dialog goes behind - which is not what i want.

    Qt Code:
    1. void MainDilaog::HandleShowhideButton()
    2. {
    3. if (m_ChannelsDlg->isVisible())
    4. {
    5. m_ChannelsDlg->close();
    6. showButton.setText(tr("Show"));
    7. }
    8. else
    9. {
    10. showButton.setText(tr("Hide"));
    11. m_ChannelsDlg->setWindowFlags(flags);
    12. m_ChannelsDlg->show();
    13. }
    To copy to clipboard, switch view to plain text mode 

    MainDilaog is derived from QGraphicsItem and QDialog.

    GK

  8. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: How to make window semi modal

    Could you prepare a minimal compilable example reproducing the problem?

Similar Threads

  1. QMainWindow modal from non-qt window?
    By hickscorp in forum Qt Programming
    Replies: 3
    Last Post: 21st November 2008, 10:10
  2. super modal window!!
    By jrodway in forum Qt Programming
    Replies: 4
    Last Post: 17th April 2008, 22:25
  3. Window OS make distclean && qmake && make one line
    By patrik08 in forum General Programming
    Replies: 4
    Last Post: 22nd March 2007, 11:43
  4. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 06:57
  5. cannot make a main window modal
    By Dark_Tower in forum Qt Programming
    Replies: 12
    Last Post: 23rd March 2006, 11:21

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.