Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Call for Presentations - Qt World Summit

    Unsolved how to open several ui from a main menu

    General and Desktop
    5
    14
    1830
    Loading More Posts
    • 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.
    • P
      Paulo G last edited by

      I was doing a graphical interface with a side menu that agreed to press one or the other or different.
      The program opens my windows perfectly. And every window the first time I enter works correctly, however, the second time I enter, nothing works.
      I suspect it is because an object is created ui every time I enter the window.
      The each button where I want the window to open I use this code.

      close();
      siguiente *prueba=new siguiente();
      prueba->showFullScreen();
      

      There is a possible solution for this.
      Greetings and thanks forward

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by mrjj

        Hi
        Something like

        put in .h file inside the class definition
        siguiente *prueba=NULL;
        
        then in 
        void ShowTheWindow() {
        if (prueba == NULL ) // only create ONCE
              prueba=new siguiente();
        
        prueba->showFullScreen();
        }
        
        then also have a function to hide it
        void HideTheWindow() {
        if (prueba == NULL ) return; // not created
        prueba->hide();
        or showNormal or what you need
        }
        
        SGaist P 2 Replies Last reply Reply Quote 1
        • SGaist
          SGaist Lifetime Qt Champion @mrjj last edited by

          Hi,
          Just a small addition to what @mrjj wrote:

          @mrjj said in how to open several ui from a main menu:

          put in .h file
          siguiente *prueba=NULL;

          That should be a member variable of your class.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply Reply Quote 1
          • P
            Paulo G @mrjj last edited by

            put in .h file inside the class definition
            siguiente *prueba=NULL;

            in mainWindows.h

            error de compilation

            jsulm 1 Reply Last reply Reply Quote 0
            • jsulm
              jsulm Lifetime Qt Champion @Paulo G last edited by

              @Paulo-G It would help if you would tell us what error you get...
              And can you show the header file so we can see where you added that line?

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply Reply Quote 1
              • P
                Paulo G last edited by

                This post is deleted!
                1 Reply Last reply Reply Quote 0
                • P
                  Paulo G last edited by

                  0_1521797213903_error.jpg
                  mainwindow.h:30: error: 'siguiente' does not name a type
                  siguiente *vRoll=NULL;

                  jsulm 1 Reply Last reply Reply Quote 0
                  • jsulm
                    jsulm Lifetime Qt Champion @Paulo G last edited by

                    @Paulo-G said in how to open several ui from a main menu:

                    mainwindow.h:30: error: 'siguiente' does not name a type

                    include the header file where siguiente is declared. Or if it is already the case is this siguiente in a namespace?
                    Maybe

                    Ui::siguiente vRoll = NULL;
                    

                    ?

                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                    1 Reply Last reply Reply Quote 2
                    • P
                      Paulo G last edited by

                      This post is deleted!
                      1 Reply Last reply Reply Quote 0
                      • P
                        Paulo G last edited by

                        En mainwindows.h
                        public:
                        Ui:: siguiente *vRoll=NULL;

                        En mainwindows.cpp

                        if (vRoll=NULL)
                        vRoll=new siguiente();
                        vRoll->show();

                        ----error
                        cannnot convert 'siguiente*' to Ui::siguiente*'
                        class Ui::siguiente has no member name show

                        1 Reply Last reply Reply Quote 0
                        • mrjj
                          mrjj Lifetime Qt Champion last edited by

                          Hi
                          siguiente seems to be a dialog so not very likely its inside
                          UI::
                          You did have
                          #include "siguiente.h" in top of the mainwindow.h ?

                          P 1 Reply Last reply Reply Quote 0
                          • P
                            Paulo G @mrjj last edited by

                            I had already added headers

                            #include "siguiente.h"

                            mrjj J.Hilk 2 Replies Last reply Reply Quote 0
                            • mrjj
                              mrjj Lifetime Qt Champion @Paulo G last edited by

                              @Paulo-G
                              If so - it should accept
                              siguiente *vRoll = NULL;
                              if it still complains, try
                              siguiente *vRoll;
                              ( and set it to null in constructor)

                              1 Reply Last reply Reply Quote 0
                              • J.Hilk
                                J.Hilk Moderators @Paulo G last edited by J.Hilk

                                @Paulo-G
                                I doubt that, in the screenshot you posted, the line after

                                #include "siguiente.h
                                is clearly
                                #include "ui_siguiente.h

                                that let's me to believe, that you placed #include "siguiente.h inside siguiente.h or siguiente.cpp

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

                                Qt Needs YOUR vote: https://bugreports.qt.io/browse/QTQAINFRA-4121


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

                                1 Reply Last reply Reply Quote 1
                                • First post
                                  Last post