Results 1 to 9 of 9

Thread: new dialog hides behind... help me please

  1. #1
    Join Date
    Jun 2009
    Location
    AKL | New Zealand
    Posts
    62
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Unhappy new dialog hides behind... help me please

    i open a dialog (dialog1) in main window, by using:

    void MainWindow::on_action_View_triggered()
    {
    if (!dbdialog)
    dbdialog = new dbDialog;
    dbdialog->show();
    dbdialog->raise();
    dbdialog->activateWindow();
    }

    then, open another dialog (dialog2) by clicking a button in dialog1

    void dbDialog::on_pushButton_search_clicked()
    {
    //dbdialog->isActiveWindow();
    QTableView *tableView2;
    tableView2 = new QTableView();
    sqlModel2 = new QSqlQueryModel();
    sqlModel2->clear();
    tableView2->setModel(sqlModel2);
    tableView2->show();
    tableView2->raise();
    tableView2->activateWindow();
    }

    my problem is that the dialog2 always hides behind dialog1, even if i click and drag dialog2.
    i disabled dbdialog->raise(); dbdialog->activateWindow(); it still does the same thing.

    is there any reason cause this happen?

    thanks in advance.

  2. #2
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: new dialog hides behind... help me please

    where is dialog2??

  3. #3
    Join Date
    Jun 2009
    Location
    AKL | New Zealand
    Posts
    62
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: new dialog hides behind... help me please

    Quote Originally Posted by MrDeath View Post
    where is dialog2??
    it is created by clicking a button in dialog1.

    is that what you asking?
    thanks

  4. #4
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: new dialog hides behind... help me please

    where is the code in
    void dbDialog:n_pushButton_search_clicked()
    which calls dialog2?

  5. #5
    Join Date
    Jun 2009
    Location
    AKL | New Zealand
    Posts
    62
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: new dialog hides behind... help me please

    Quote Originally Posted by MrDeath View Post
    where is the code in
    void dbDialog:n_pushButton_search_clicked()
    which calls dialog2?
    hi Mrdeath, thanks for your reply. the dialog2 in my program is actually viewtable2. sorry about the confusing.
    here is the code to open viewtable2 (i said "dialog2"):

    void dbDialog::on_pushButton_search_clicked()
    {
    //dbdialog->isActiveWindow();
    QTableView *tableView2;
    tableView2 = new QTableView();
    sqlModel2 = new QSqlQueryModel();
    sqlModel2->clear();
    tableView2->setModel(sqlModel2);
    tableView2->show();
    tableView2->raise();
    tableView2->activateWindow();
    }

    i really appreciate your help.

  6. #6
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: new dialog hides behind... help me please

    okay... this is the problem of parent and directly using tableview...

    do it like this...

    Qt Code:
    1. void dbDialog::on_pushButton_search_clicked()
    2. {
    3.  
    4. //instead of creating this again n again.. make it member
    5. QDialog* dlg=new QDialog(this);
    6. layout->setMargin(0);layout->setSpacing(0);
    7.  
    8. //instead of creating this again n again.. make it member
    9. QTableView *tableView2;
    10. tableView2 = new QTableView();
    11. sqlModel2 = new QSqlQueryModel();
    12. sqlModel2->clear();
    13. tableView2->setModel(sqlModel2);
    14.  
    15. layout->addWidget(tableView2);
    16.  
    17. dlg->exec();
    18.  
    19. //dlg->show();
    20. //dlg->raise();
    21. //dlg->activateWindow();
    22. }
    To copy to clipboard, switch view to plain text mode 
    you should create your own class inherited from QDialog.
    Last edited by nish; 12th June 2009 at 01:52. Reason: missing [code] tags

  7. #7
    Join Date
    Jun 2009
    Location
    AKL | New Zealand
    Posts
    62
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: new dialog hides behind... help me please

    thanks Mrdeath, it works

    instead of just copy your code, would you like to give me a brief explanation of "it is a problem of parent and directly using tableview"?
    i am a newbie in c++.

    thanks for your time
    you have a good weekend

  8. #8
    Join Date
    Jun 2007
    Location
    India
    Posts
    1,042
    Thanks
    8
    Thanked 133 Times in 128 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: new dialog hides behind... help me please

    QDialog, and QMainWindow are generally the topLevel windows that should be used if u are using something independently.

    because they provide several simplified top level window manager functions and return values.

    secondly,,, every widget is shown in the geometry of its parent widget. since your tablewidget did not had any parent, it causes random behaviour and can be displayed anywhere... when i tried to display without parent it was showing at top left corner of the screen , and sometimes in middle

  9. The following user says thank you to nish for this useful post:

    cooper (14th June 2009)

  10. #9
    Join Date
    Jun 2009
    Location
    AKL | New Zealand
    Posts
    62
    Thanks
    21
    Thanked 3 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: new dialog hides behind... help me please

    Quote Originally Posted by MrDeath View Post
    QDialog, and QMainWindow are generally the topLevel windows that should be used if u are using something independently.

    ...

    anywhere... when i tried to display without parent it was showing at top left corner of the screen , and sometimes in middle
    thanks Mrdeath, your explanation is quit helpful to me

Similar Threads

  1. Issue with Modelless dialog on Mac
    By Satyanarayana Chebrolu in forum Qt Programming
    Replies: 0
    Last Post: 24th February 2009, 10:10
  2. Dialog is not closing
    By manmohan in forum Newbie
    Replies: 5
    Last Post: 1st December 2008, 17:04
  3. Replies: 9
    Last Post: 13th August 2008, 18:07
  4. Resizing the dialog boxes
    By anju123 in forum Qt Programming
    Replies: 4
    Last Post: 14th September 2007, 10:41
  5. QGraphicsView: Dialog Position Doubt
    By arjunasd in forum Qt Programming
    Replies: 1
    Last Post: 6th August 2007, 17:48

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.