Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. is there any way to restore the GUI to same state after QMainWindow->GUI

is there any way to restore the GUI to same state after QMainWindow->GUI

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 4 Posters 1.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Q Offline
    Q Offline
    Qt Enthusiast
    wrote on last edited by
    #1

    Hi have
    I have QT GUI , which I close by usign QMainWindow->close . As per the documentation of QMainWindow close hide the GUI . but I am not getting a direct where I can unhide the GUI to same state

    Regards
    Roshni

    J.HilkJ 1 Reply Last reply
    0
    • E Offline
      E Offline
      Eligijus
      wrote on last edited by
      #2

      Call widgets show slot.
      mainwindow->show();
      http://doc.qt.io/qt-5/qwidget.html#show

      1 Reply Last reply
      1
      • Q Qt Enthusiast

        Hi have
        I have QT GUI , which I close by usign QMainWindow->close . As per the documentation of QMainWindow close hide the GUI . but I am not getting a direct where I can unhide the GUI to same state

        Regards
        Roshni

        J.HilkJ Offline
        J.HilkJ Offline
        J.Hilk
        Moderators
        wrote on last edited by
        #3

        @Qt-Enthusiast
        I believe the default atribute of QMainWindow is set with Qt::WA_DeleteOnClose that means when you close your mainwindow it also gets deleted and theres no way to just show it again. WidgetAttributes

        In your case, the easiest way is to simply call QWidget::hide() and QWidget::show()


        Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


        Q: What's that?
        A: It's blue light.
        Q: What does it do?
        A: It turns blue.

        1 Reply Last reply
        1
        • dheerendraD Offline
          dheerendraD Offline
          dheerendra
          Qt Champions 2022
          wrote on last edited by
          #4

          Try with simple example like this.

          int main(int argc, char *argv[])
          {
          QApplication a(argc, argv);
          MainWindow w;
          w.show();

          QPushButton b1("Close");
          QPushButton b2("Show");
          
          QObject::connect(&b1,SIGNAL(clicked()),&w,SLOT(close()));
          QObject::connect(&b2,SIGNAL(clicked()),&w,SLOT(show()));
          
          
          b1.show();
          b2.show();
          return a.exec();
          

          }

          Dheerendra
          @Community Service
          Certified Qt Specialist
          http://www.pthinks.com

          1 Reply Last reply
          2

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved