Results 1 to 15 of 15

Thread: Reopen the MainWindow

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows

    Default Reopen the MainWindow

    Hi guys! I was trying to show mainwindow after to hide that, but I couldn`t do that.

    First I hide the mainwindow in the pushbutton action and open a dialog window:
    Qt Code:
    1. void MainWindow::on_NewTest_clicked()
    2. {
    3. this->hide();
    4. NewTest newtest;
    5. newtest.setModal(true);
    6. newtest.exec();
    7.  
    8. }
    To copy to clipboard, switch view to plain text mode 

    Then in this dialog window I would like to add a button to return to the mainwindow, but I searched and I didn`t found anything about it. Thanks guys!

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

    Default Re: Reopen the MainWindow

    To show a window simply call show() on it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reopen the MainWindow

    I tried that but it didn`t work. Just show a window for half of a second and then close it. I tried to call MainWindow using this code:
    Qt Code:
    1. void NewTest::on_Home_clicked()
    2. {
    3. MainWindow w;
    4. w.show();
    5.  
    6. }
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Reopen the MainWindow

    The object goes out of scope when the function ends.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    May 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reopen the MainWindow

    So, how do I do that? I know how to open and close QDialog, but in the QDialog I would like to have a button that close the QDialog and reopen the QMainWindow

  6. #6
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android
    Thanked 342 Times in 324 Posts

    Default Re: Reopen the MainWindow

    So, how do I do that?
    The object goes out of scope when the function ends.
    Do you understand what is the meaning of the above sentence ?

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

    Default Re: Reopen the MainWindow

    Quote Originally Posted by thibs View Post
    reopen the QMainWindow
    Your code doesn't re-open anything. It creates a new window and shows it. And then it gets deleted.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #8
    Join Date
    May 2015
    Posts
    22
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Reopen the MainWindow

    I understand, I just wanted to show what I was trying to do. Do you guys know how do I show the MainWindow inside a pushbutton event in another class after it be hidden

  9. #9
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts

    Default Re: Reopen the MainWindow

    Do you want to show the window again without closing the dialog?

    Cheers,
    _

Similar Threads

  1. mainwindow
    By kaals in forum Newbie
    Replies: 1
    Last Post: 25th August 2012, 20:25
  2. Replies: 0
    Last Post: 6th November 2011, 09:22
  3. Replies: 1
    Last Post: 12th April 2011, 09:53
  4. Replies: 1
    Last Post: 6th July 2010, 12:03
  5. MainWindow
    By amagdy.ibrahim in forum Newbie
    Replies: 6
    Last Post: 14th June 2008, 14:12

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.