Results 1 to 6 of 6

Thread: Open back a closed frame?

  1. #1
    Join Date
    Jan 2012
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default Open back a closed frame?

    Escenario:

    1. Main window opens
    2. I click a pushbutton to go the help window
    3. Help window opens, main window closes


    That's fine... but when I add a pushbutton to the help window to go the main window again, I get a compilation error... I use the exact same code I use to open a new frame... but I don't know what is happening... apparently it has something to do with the fact that the main window is already declared or something...

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

    Default Re: Open back a closed frame?

    We don't know what is happening either. You have the advantage of having actually seen the error.
    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
    Jan 2012
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Open back a closed frame?

    Well... lets say I have:

    mainwindow.h
    mainwindow.cpp
    aboutwindow.h
    aboutwindow.cpp

    In order for mainwindow to open aboutwindow using a pushbutton I have to do this:

    In mainwindow.h, I do the following modifications.

    #include aboutwindow.h //Include the header of the window I wanna open

    on public slots:

    void openAboutWindow(); //Declare a function to open the window

    on private:
    AboutWindow * windowAbout; //I declare a var for the window

    on private slots:
    void on_buttonabout_clicked(); //Thats the function to call when I click on the push button

    And then on mainwindow.cpp I add the following code:


    void MainWindow :: on_buttonabout_clicked() //This is executed once I click the button
    {
    openAboutWindow();

    }

    void MainWindow :: openAboutWindow() //This is called by the previous function
    {n
    close(); //This closes the current window
    windowAbout = new AboutWindow(this);
    windowAbout->show(); //This shows the "about" window
    }



    ----


    That works perfectly to call a new window that I haven't opened before.... But once I do that, let's say I want to go back to the main window... so in the aboutwindow.ui I add a new push button, and I do the exact same code, except this time goes from aboutwindow to mainwindow... but it doesn't work... gives me a compilation error:

    "ISO C++ forbids the declaration of MainWindow with no type", that is the on private line I added...

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

    Default Re: Open back a closed frame?

    You probably end up with:

    file1.h: #include "file2.h"
    file2.h: #include "file1.h"

    You have to sort out the circular dependency. Forward declarations and refactoring are common solutions to the problem.
    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
    Jan 2012
    Posts
    15
    Qt products
    Qt3
    Platforms
    Windows

    Default Re: Open back a closed frame?

    and how could I do that? I'm just starting with QT and C++... just an idea could be useful, thanks in advance.

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

    Default Re: Open back a closed frame?

    I have already given you two ideas. Type them into your favourite web search engine and see what pops out.
    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.


Similar Threads

  1. Replies: 7
    Last Post: 23rd April 2011, 02:29
  2. Replies: 1
    Last Post: 18th January 2011, 12:48
  3. How to determine if dock is open or closed
    By rbp in forum Qt Programming
    Replies: 2
    Last Post: 9th October 2009, 08:03
  4. Open FileDialog showing Back of the Widget in Mac
    By shyam prasad in forum Qt Programming
    Replies: 1
    Last Post: 19th April 2007, 06:33
  5. Replies: 7
    Last Post: 28th January 2007, 11:07

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.