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. how to open several ui from a main menu

how to open several ui from a main menu

Scheduled Pinned Locked Moved Unsolved General and Desktop
14 Posts 5 Posters 2.4k Views
  • 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 Offline
    P Offline
    Paulo G
    wrote on last edited by
    #1

    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
    0
    • mrjjM Offline
      mrjjM Offline
      mrjj
      Lifetime Qt Champion
      wrote on last edited by mrjj
      #2

      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
      }
      
      SGaistS P 2 Replies Last reply
      1
      • mrjjM 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
        }
        
        SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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
        1
        • mrjjM 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
          }
          
          P Offline
          P Offline
          Paulo G
          wrote on last edited by
          #4

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

          in mainWindows.h

          error de compilation

          jsulmJ 1 Reply Last reply
          0
          • P Paulo G

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

            in mainWindows.h

            error de compilation

            jsulmJ Offline
            jsulmJ Offline
            jsulm
            Lifetime Qt Champion
            wrote on last edited by
            #5

            @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
            1
            • P Offline
              P Offline
              Paulo G
              wrote on last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              0
              • P Offline
                P Offline
                Paulo G
                wrote on last edited by
                #7

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

                jsulmJ 1 Reply Last reply
                0
                • P Paulo G

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

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @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
                  2
                  • P Offline
                    P Offline
                    Paulo G
                    wrote on last edited by
                    #9
                    This post is deleted!
                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      Paulo G
                      wrote on last edited by
                      #10

                      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
                      0
                      • mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by
                        #11

                        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
                        0
                        • mrjjM mrjj

                          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 Offline
                          P Offline
                          Paulo G
                          wrote on last edited by
                          #12

                          I had already added headers

                          #include "siguiente.h"

                          mrjjM J.HilkJ 2 Replies Last reply
                          0
                          • P Paulo G

                            I had already added headers

                            #include "siguiente.h"

                            mrjjM Offline
                            mrjjM Offline
                            mrjj
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            @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
                            0
                            • P Paulo G

                              I had already added headers

                              #include "siguiente.h"

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

                              @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


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

                              1 Reply Last reply
                              1

                              • Login

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