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 Updated to NodeBB v4.3 + New Features

How to Implement the coding part of this UI Integration?

Scheduled Pinned Locked Moved Solved General and Desktop
23 Posts 4 Posters 2.6k 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.
  • jsulmJ jsulm

    @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)!

    Aviral 0A Offline
    Aviral 0A Offline
    Aviral 0
    wrote on 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 jsulmJ 2 Replies Last reply
    0
    • Aviral 0A Aviral 0

      @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 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.

      Aviral 0A 1 Reply Last reply
      0
      • Aviral 0A Aviral 0

        @jsulm Using this:

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

        Application is crashing with both above suggestions.

        jsulmJ Online
        jsulmJ Online
        jsulm
        Lifetime Qt Champion
        wrote on 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.

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

        Aviral 0A 1 Reply Last reply
        0
        • jsulmJ jsulm

          @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.

          Aviral 0A Offline
          Aviral 0A Offline
          Aviral 0
          wrote on last edited by
          #15
          This post is deleted!
          jsulmJ 1 Reply Last reply
          0
          • J.HilkJ J.Hilk

            @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 ?

            Aviral 0A Offline
            Aviral 0A Offline
            Aviral 0
            wrote on 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
            0
            • Aviral 0A Aviral 0

              @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 Online
              JonBJ Online
              JonB
              wrote on 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 :)

              Aviral 0A 1 Reply Last reply
              0
              • Aviral 0A Aviral 0

                This post is deleted!

                jsulmJ Online
                jsulmJ Online
                jsulm
                Lifetime Qt Champion
                wrote on 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.

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

                JonBJ 1 Reply Last reply
                1
                • JonBJ JonB

                  @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 :)

                  Aviral 0A Offline
                  Aviral 0A Offline
                  Aviral 0
                  wrote on 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();
                  
                  jsulmJ 1 Reply Last reply
                  0
                  • Aviral 0A Aviral 0

                    @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();
                    
                    jsulmJ Online
                    jsulmJ Online
                    jsulm
                    Lifetime Qt Champion
                    wrote on 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);
                    

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

                    Aviral 0A 1 Reply Last reply
                    1
                    • jsulmJ jsulm

                      @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 Online
                      JonBJ Online
                      JonB
                      wrote on last edited by JonB
                      #21

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

                      Probably because ui->page page of your stacked widget is shown and not the other you're adding.

                      I think ui->stackedWidget->addWidget(logDisplay) adds logDisplay as another widget page after the page one you show in your screenshot, but does not make the new one be the one shown.

                      After the addWidget() try

                      ui->stackedWidget->setCurrentWidget(logDisplay);
                      

                      Is that what you expected to see?

                      Having said that. I am not at all convinced you want that page already in your QStackedWidget? Depending on what you want, either get rid of that or go something like:

                      ui->page->setLayout(new QVBoxLayout);
                      ui->page->layout()->addWidget(LogDisplay);
                      
                      Aviral 0A 1 Reply Last reply
                      0
                      • Aviral 0A Aviral 0 has marked this topic as solved on
                      • jsulmJ jsulm

                        @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);
                        
                        Aviral 0A Offline
                        Aviral 0A Offline
                        Aviral 0
                        wrote on last edited by
                        #22

                        @jsulm It worked, thankyou

                        1 Reply Last reply
                        0
                        • JonBJ JonB

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

                          Probably because ui->page page of your stacked widget is shown and not the other you're adding.

                          I think ui->stackedWidget->addWidget(logDisplay) adds logDisplay as another widget page after the page one you show in your screenshot, but does not make the new one be the one shown.

                          After the addWidget() try

                          ui->stackedWidget->setCurrentWidget(logDisplay);
                          

                          Is that what you expected to see?

                          Having said that. I am not at all convinced you want that page already in your QStackedWidget? Depending on what you want, either get rid of that or go something like:

                          ui->page->setLayout(new QVBoxLayout);
                          ui->page->layout()->addWidget(LogDisplay);
                          
                          Aviral 0A Offline
                          Aviral 0A Offline
                          Aviral 0
                          wrote on last edited by
                          #23

                          @JonB Thankyou for your help too! really appreciate efforts!

                          1 Reply Last reply
                          0

                          • Login

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