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 Implement the coding part of this UI Integration?
Forum Update on Monday, May 27th 2025

How to Implement the coding part of this UI Integration?

Scheduled Pinned Locked Moved Solved General and Desktop
23 Posts 4 Posters 2.2k 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.
  • A Offline
    A Offline
    Aviral 0
    wrote on 20 Feb 2023, 04:07 last edited by
    #1

    Hi all, I have a prebuilt LogDisplay QT Application, and I want to Integrate it into my current QT GUI application.
    I have used stacked widget as the container for the application and using only 1 page of that. Suggest if some another good option other than QStackWidget?

    I have promoted the QStackWidget to LogDisplay class.
    Screenshot 2023-02-20 093242.png

    Please someone tell me the mainwindow coding part to call the logdisplay class in that QStacked widget.

    J 1 Reply Last reply 20 Feb 2023, 06:17
    0
    • A Aviral 0
      20 Feb 2023, 08:55

      @JonB Yeah! Do you have any idea what I am doing wrong here:

      ui->page->setLayout(new QHBoxLayout);
          LogDisplay *logDisplay = new LogDisplay(ui->page);
      
         // ui->stackedWidget->layout()->addWidget(logDisplay);
      
          ui->stackedWidget->addWidget(logDisplay);
          ui->stackedWidget->show();
      
      J Offline
      J Offline
      jsulm
      Lifetime Qt Champion
      wrote on 20 Feb 2023, 09:02 last edited by
      #20

      @Aviral-0 said in How to Implement the coding part of this UI Integration?:

      Do you have any idea what I am doing wrong here

      What do you expect this code to do?
      You added a layout to ui->page. Then you added logDisplay as another page. But you wanted to have logDisplay on ui->page, right? Can you please read more carefully? I wrote before:

      // Or, if ui->page has a layout:
      LogDisplay *logDisplay = new LogDisplay();
      ui->page->layout()->addWidget(logDisplay);
      

      So, don't you think your code should be like:

      // Or, if ui->page has a layout:
      LogDisplay *logDisplay = new LogDisplay();
      ui->page->setLayout(new QHBoxLayout);
      ui->page->layout()->addWidget(logDisplay);
      
      A 1 Reply Last reply 20 Feb 2023, 09:22
      1
      • A Aviral 0
        20 Feb 2023, 04:07

        Hi all, I have a prebuilt LogDisplay QT Application, and I want to Integrate it into my current QT GUI application.
        I have used stacked widget as the container for the application and using only 1 page of that. Suggest if some another good option other than QStackWidget?

        I have promoted the QStackWidget to LogDisplay class.
        Screenshot 2023-02-20 093242.png

        Please someone tell me the mainwindow coding part to call the logdisplay class in that QStacked widget.

        J Offline
        J Offline
        jsulm
        Lifetime Qt Champion
        wrote on 20 Feb 2023, 06:17 last edited by
        #2

        @Aviral-0 said in How to Implement the coding part of this UI Integration?:

        Suggest if some another good option other than QStackWidget?

        Why?

        "Please someone tell me the mainwindow coding part to call the logdisplay class in that QStacked widget." - what "coding part"? What does "call the logdisplay class" mean?
        Please ask clear questions...

        A 1 Reply Last reply 20 Feb 2023, 06:31
        0
        • J jsulm
          20 Feb 2023, 06:17

          @Aviral-0 said in How to Implement the coding part of this UI Integration?:

          Suggest if some another good option other than QStackWidget?

          Why?

          "Please someone tell me the mainwindow coding part to call the logdisplay class in that QStacked widget." - what "coding part"? What does "call the logdisplay class" mean?
          Please ask clear questions...

          A Offline
          A Offline
          Aviral 0
          wrote on 20 Feb 2023, 06:31 last edited by Aviral 0
          #3

          @jsulm Actually I am trying to add the LogDisplay application integrate with another UI application.
          I have a QWidget which contains QStackedView and Using QstackedView I am displaying LogDisplay class.

          QWidget *widget = new QWidget(this);
              QStackedWidget *stackedWidget = new QStackedWidget(this);
              LogDisplay *logDisplay = new LogDisplay(this);
          
              //stackedWidget->setCurrentWidget(widget);
              widget->setLayout(new QHBoxLayout);
              widget->layout()->addWidget(stackedWidget);
              setCentralWidget(stackedWidget);
                      stackedWidget->addWidget(logDisplay);
                      stackedWidget->show();
          

          But the Logdisplay class is taking the whole screen of application instread of what I am giving the position and size in UI design. How to solve this?
          Here the output I am getting:
          Screenshot 2023-02-20 120313.png
          in Full Screen.
          But I defined the stackedwidget as:
          Screenshot 2023-02-20 120336.png

          J 2 Replies Last reply 20 Feb 2023, 06:34
          0
          • A Aviral 0
            20 Feb 2023, 06:31

            @jsulm Actually I am trying to add the LogDisplay application integrate with another UI application.
            I have a QWidget which contains QStackedView and Using QstackedView I am displaying LogDisplay class.

            QWidget *widget = new QWidget(this);
                QStackedWidget *stackedWidget = new QStackedWidget(this);
                LogDisplay *logDisplay = new LogDisplay(this);
            
                //stackedWidget->setCurrentWidget(widget);
                widget->setLayout(new QHBoxLayout);
                widget->layout()->addWidget(stackedWidget);
                setCentralWidget(stackedWidget);
                        stackedWidget->addWidget(logDisplay);
                        stackedWidget->show();
            

            But the Logdisplay class is taking the whole screen of application instread of what I am giving the position and size in UI design. How to solve this?
            Here the output I am getting:
            Screenshot 2023-02-20 120313.png
            in Full Screen.
            But I defined the stackedwidget as:
            Screenshot 2023-02-20 120336.png

            J Offline
            J Offline
            jsulm
            Lifetime Qt Champion
            wrote on 20 Feb 2023, 06:34 last edited by
            #4
            This post is deleted!
            1 Reply Last reply
            0
            • A Aviral 0
              20 Feb 2023, 06:31

              @jsulm Actually I am trying to add the LogDisplay application integrate with another UI application.
              I have a QWidget which contains QStackedView and Using QstackedView I am displaying LogDisplay class.

              QWidget *widget = new QWidget(this);
                  QStackedWidget *stackedWidget = new QStackedWidget(this);
                  LogDisplay *logDisplay = new LogDisplay(this);
              
                  //stackedWidget->setCurrentWidget(widget);
                  widget->setLayout(new QHBoxLayout);
                  widget->layout()->addWidget(stackedWidget);
                  setCentralWidget(stackedWidget);
                          stackedWidget->addWidget(logDisplay);
                          stackedWidget->show();
              

              But the Logdisplay class is taking the whole screen of application instread of what I am giving the position and size in UI design. How to solve this?
              Here the output I am getting:
              Screenshot 2023-02-20 120313.png
              in Full Screen.
              But I defined the stackedwidget as:
              Screenshot 2023-02-20 120336.png

              J Offline
              J Offline
              jsulm
              Lifetime Qt Champion
              wrote on 20 Feb 2023, 06:37 last edited by
              #5

              @Aviral-0 said in How to Implement the coding part of this UI Integration?:

              But the Logdisplay class is taking the whole screen of application instread of what I am giving the position and size in UI design. How to solve this?

              You are NOT using what you defined in UI! You're adding a NEW QWidget which is then replacing the central widget of your main window! You are also creating a NEW QStackedWidget instead of using the one you added in UI! Why don't you use ui->stackedWidget instead of doing all this?! ui->stackedWidget is the stacked widget you added in your ui...

              A 1 Reply Last reply 20 Feb 2023, 06:45
              1
              • J jsulm
                20 Feb 2023, 06:37

                @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                But the Logdisplay class is taking the whole screen of application instread of what I am giving the position and size in UI design. How to solve this?

                You are NOT using what you defined in UI! You're adding a NEW QWidget which is then replacing the central widget of your main window! You are also creating a NEW QStackedWidget instead of using the one you added in UI! Why don't you use ui->stackedWidget instead of doing all this?! ui->stackedWidget is the stacked widget you added in your ui...

                A Offline
                A Offline
                Aviral 0
                wrote on 20 Feb 2023, 06:45 last edited by
                #6

                @jsulm Can you help me write it up?

                J 1 Reply Last reply 20 Feb 2023, 06:48
                0
                • A Aviral 0
                  20 Feb 2023, 06:45

                  @jsulm Can you help me write it up?

                  J Offline
                  J Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on 20 Feb 2023, 06:48 last edited by
                  #7

                  @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                  Can you help me write it up?

                  Write what?
                  Simply use ui->stackedWidget to access your stacked widget, there is no need for the code you posted because you already added a stacked widget in designer...

                  A 1 Reply Last reply 20 Feb 2023, 06:50
                  0
                  • J jsulm
                    20 Feb 2023, 06:48

                    @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                    Can you help me write it up?

                    Write what?
                    Simply use ui->stackedWidget to access your stacked widget, there is no need for the code you posted because you already added a stacked widget in designer...

                    A Offline
                    A Offline
                    Aviral 0
                    wrote on 20 Feb 2023, 06:50 last edited by
                    #8

                    @jsulm how to add LogDisplay object in ui->stackedwidget?

                    J 1 Reply Last reply 20 Feb 2023, 06:52
                    0
                    • A Aviral 0
                      20 Feb 2023, 06:50

                      @jsulm how to add LogDisplay object in ui->stackedwidget?

                      J Offline
                      J Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on 20 Feb 2023, 06:52 last edited by
                      #9

                      @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                      how to add LogDisplay object in ui->stackedwidget?

                      Like shown in documentation: https://doc.qt.io/qt-6/qstackedwidget.html Did you read it?

                      stackedWidget->addWidget(firstPageWidget);
                      

                      Before you ask:

                      LogDisplay *logDisplay = new LogDisplay(this);
                      ui->stackedWidget->addWidget(logDisplay);
                      
                      A 1 Reply Last reply 20 Feb 2023, 07:00
                      0
                      • J jsulm
                        20 Feb 2023, 06:52

                        @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                        how to add LogDisplay object in ui->stackedwidget?

                        Like shown in documentation: https://doc.qt.io/qt-6/qstackedwidget.html Did you read it?

                        stackedWidget->addWidget(firstPageWidget);
                        

                        Before you ask:

                        LogDisplay *logDisplay = new LogDisplay(this);
                        ui->stackedWidget->addWidget(logDisplay);
                        
                        A Offline
                        A Offline
                        Aviral 0
                        wrote on 20 Feb 2023, 07:00 last edited by
                        #10

                        @jsulm The Object of Page in StackedWidget is "page" in UI,
                        and I have implemented like this:

                         ui->stackedWidget->addWidget(ui->page);
                            LogDisplay *logDisplay = new LogDisplay(this);
                            ui->stackedWidget->addWidget(logDisplay);
                        

                        Still No Stacked window is shown. Please Help!

                        J 1 Reply Last reply 20 Feb 2023, 07:05
                        0
                        • A Aviral 0
                          20 Feb 2023, 07:00

                          @jsulm The Object of Page in StackedWidget is "page" in UI,
                          and I have implemented like this:

                           ui->stackedWidget->addWidget(ui->page);
                              LogDisplay *logDisplay = new LogDisplay(this);
                              ui->stackedWidget->addWidget(logDisplay);
                          

                          Still No Stacked window is shown. Please Help!

                          J Offline
                          J Offline
                          jsulm
                          Lifetime Qt Champion
                          wrote on 20 Feb 2023, 07:05 last edited by jsulm
                          #11

                          @Aviral-0 If you want to add your logDisplay to an existing widget in stackedwidget (for whatever reason) then do so:

                          LogDisplay *logDisplay = new LogDisplay(ui->page);
                          // Or, if ui->page has a layout:
                          LogDisplay *logDisplay = new LogDisplay();
                          ui->page->layout()->addWidget(logDisplay);
                          

                          Then please don't call ui->stackedWidget->addWidget(logDisplay)!

                          A 1 Reply Last reply 20 Feb 2023, 07:12
                          0
                          • J jsulm
                            20 Feb 2023, 07:05

                            @Aviral-0 If you want to add your logDisplay to an existing widget in stackedwidget (for whatever reason) then do so:

                            LogDisplay *logDisplay = new LogDisplay(ui->page);
                            // Or, if ui->page has a layout:
                            LogDisplay *logDisplay = new LogDisplay();
                            ui->page->layout()->addWidget(logDisplay);
                            

                            Then please don't call ui->stackedWidget->addWidget(logDisplay)!

                            A Offline
                            A Offline
                            Aviral 0
                            wrote on 20 Feb 2023, 07:12 last edited by
                            #12

                            @jsulm Using this:

                            ui->stackedWidget->addWidget(ui->page);
                                LogDisplay *logDisplay = new LogDisplay();
                            
                                ui->page->layout()->addWidget(logDisplay);
                            

                            Application is crashing with both above suggestions.

                            J.HilkJ J 2 Replies Last reply 20 Feb 2023, 07:14
                            0
                            • A Aviral 0
                              20 Feb 2023, 07:12

                              @jsulm Using this:

                              ui->stackedWidget->addWidget(ui->page);
                                  LogDisplay *logDisplay = new LogDisplay();
                              
                                  ui->page->layout()->addWidget(logDisplay);
                              

                              Application is crashing with both above suggestions.

                              J.HilkJ Online
                              J.HilkJ Online
                              J.Hilk
                              Moderators
                              wrote on 20 Feb 2023, 07:14 last edited by
                              #13

                              @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                              ui->stackedWidget->addWidget(ui->page);
                              LogDisplay *logDisplay = new LogDisplay();

                              where, for the love of god, did you see this as a suggestion ?


                              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.

                              A 1 Reply Last reply 20 Feb 2023, 07:27
                              0
                              • A Aviral 0
                                20 Feb 2023, 07:12

                                @jsulm Using this:

                                ui->stackedWidget->addWidget(ui->page);
                                    LogDisplay *logDisplay = new LogDisplay();
                                
                                    ui->page->layout()->addWidget(logDisplay);
                                

                                Application is crashing with both above suggestions.

                                J Offline
                                J Offline
                                jsulm
                                Lifetime Qt Champion
                                wrote on 20 Feb 2023, 07:15 last edited by
                                #14

                                @Aviral-0 Please, I never said you need ui->stackedWidget->addWidget(ui->page)!
                                ui->page was already added to stacked widget in UI! Please think about what you're doing!
                                This should work:

                                LogDisplay *logDisplay = new LogDisplay();
                                ui->page->layout()->addWidget(logDisplay);
                                

                                If it crashes then please first use a debugger to see why. Debugger is really one of the most basic tools of a programmer.

                                A 1 Reply Last reply 20 Feb 2023, 07:23
                                0
                                • J jsulm
                                  20 Feb 2023, 07:15

                                  @Aviral-0 Please, I never said you need ui->stackedWidget->addWidget(ui->page)!
                                  ui->page was already added to stacked widget in UI! Please think about what you're doing!
                                  This should work:

                                  LogDisplay *logDisplay = new LogDisplay();
                                  ui->page->layout()->addWidget(logDisplay);
                                  

                                  If it crashes then please first use a debugger to see why. Debugger is really one of the most basic tools of a programmer.

                                  A Offline
                                  A Offline
                                  Aviral 0
                                  wrote on 20 Feb 2023, 07:23 last edited by
                                  #15
                                  This post is deleted!
                                  J 1 Reply Last reply 20 Feb 2023, 07:56
                                  0
                                  • J.HilkJ J.Hilk
                                    20 Feb 2023, 07:14

                                    @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                                    ui->stackedWidget->addWidget(ui->page);
                                    LogDisplay *logDisplay = new LogDisplay();

                                    where, for the love of god, did you see this as a suggestion ?

                                    A Offline
                                    A Offline
                                    Aviral 0
                                    wrote on 20 Feb 2023, 07:27 last edited by
                                    #16

                                    @J-Hilk Hi, I am sorry for some silly questions, I am new to programming job and it doesn't interest me much, but gotta do it for the living. Just to cover my basic needs so that I can do what interests me! Hope you'll understand!

                                    JonBJ 1 Reply Last reply 20 Feb 2023, 07:45
                                    0
                                    • A Aviral 0
                                      20 Feb 2023, 07:27

                                      @J-Hilk Hi, I am sorry for some silly questions, I am new to programming job and it doesn't interest me much, but gotta do it for the living. Just to cover my basic needs so that I can do what interests me! Hope you'll understand!

                                      JonBJ Offline
                                      JonBJ Offline
                                      JonB
                                      wrote on 20 Feb 2023, 07:45 last edited by
                                      #17

                                      @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                                      I am new to programming job and it doesn't interest me much, but gotta do it for the living.

                                      Ummm.....

                                      Just to cover my basic needs so that I can do what interests me!

                                      I don't know how easy it will be to use programming to cover your "basic needs" while you go off doing whatever you actually want to do! Programming is (relatively) hard, it certainly requires some effort to understand what is going on! All the best :)

                                      A 1 Reply Last reply 20 Feb 2023, 08:55
                                      0
                                      • A Aviral 0
                                        20 Feb 2023, 07:23

                                        This post is deleted!

                                        J Offline
                                        J Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on 20 Feb 2023, 07:56 last edited by
                                        #18

                                        @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                                        Launches the application but I see no stackedwidget in it.

                                        Probably because ui->page page of your stacked widget is shown and not the other you're adding.
                                        I already told you: if your app crashes use debugger to see why. I guess ui->page has no layout, so ui->page->layout() returns nullptr. Add a layout to it then.

                                        JonBJ 1 Reply Last reply 20 Feb 2023, 09:05
                                        1
                                        • JonBJ JonB
                                          20 Feb 2023, 07:45

                                          @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                                          I am new to programming job and it doesn't interest me much, but gotta do it for the living.

                                          Ummm.....

                                          Just to cover my basic needs so that I can do what interests me!

                                          I don't know how easy it will be to use programming to cover your "basic needs" while you go off doing whatever you actually want to do! Programming is (relatively) hard, it certainly requires some effort to understand what is going on! All the best :)

                                          A Offline
                                          A Offline
                                          Aviral 0
                                          wrote on 20 Feb 2023, 08:55 last edited by
                                          #19

                                          @JonB Yeah! Do you have any idea what I am doing wrong here:

                                          ui->page->setLayout(new QHBoxLayout);
                                              LogDisplay *logDisplay = new LogDisplay(ui->page);
                                          
                                             // ui->stackedWidget->layout()->addWidget(logDisplay);
                                          
                                              ui->stackedWidget->addWidget(logDisplay);
                                              ui->stackedWidget->show();
                                          
                                          J 1 Reply Last reply 20 Feb 2023, 09:02
                                          0
                                          • A Aviral 0
                                            20 Feb 2023, 08:55

                                            @JonB Yeah! Do you have any idea what I am doing wrong here:

                                            ui->page->setLayout(new QHBoxLayout);
                                                LogDisplay *logDisplay = new LogDisplay(ui->page);
                                            
                                               // ui->stackedWidget->layout()->addWidget(logDisplay);
                                            
                                                ui->stackedWidget->addWidget(logDisplay);
                                                ui->stackedWidget->show();
                                            
                                            J Offline
                                            J Offline
                                            jsulm
                                            Lifetime Qt Champion
                                            wrote on 20 Feb 2023, 09:02 last edited by
                                            #20

                                            @Aviral-0 said in How to Implement the coding part of this UI Integration?:

                                            Do you have any idea what I am doing wrong here

                                            What do you expect this code to do?
                                            You added a layout to ui->page. Then you added logDisplay as another page. But you wanted to have logDisplay on ui->page, right? Can you please read more carefully? I wrote before:

                                            // Or, if ui->page has a layout:
                                            LogDisplay *logDisplay = new LogDisplay();
                                            ui->page->layout()->addWidget(logDisplay);
                                            

                                            So, don't you think your code should be like:

                                            // Or, if ui->page has a layout:
                                            LogDisplay *logDisplay = new LogDisplay();
                                            ui->page->setLayout(new QHBoxLayout);
                                            ui->page->layout()->addWidget(logDisplay);
                                            
                                            A 1 Reply Last reply 20 Feb 2023, 09:22
                                            1

                                            1/23

                                            20 Feb 2023, 04:07

                                            • Login

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