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 get Widget from UI file
Qt 6.11 is out! See what's new in the release blog

How to get Widget from UI file

Scheduled Pinned Locked Moved Unsolved General and Desktop
19 Posts 5 Posters 2.8k Views 2 Watching
  • 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.
  • SPlattenS SPlatten

    @JonB , I'm just trying to meet a request, which something shown in the tab is in a fault state the tab itself should be shown in a red background. The existing UI has the tabs and controls, but I cannot get this to work with the existing tabs in the UI, if I create the tabs from scratch it works.

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

    @SPlatten have you considered checking the auto generated "ui_class.h"file and simply taking the c++ code of your tabs from there and than using that code to create them yourself?


    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.

    SPlattenS 2 Replies Last reply
    0
    • J.HilkJ J.Hilk

      @SPlatten have you considered checking the auto generated "ui_class.h"file and simply taking the c++ code of your tabs from there and than using that code to create them yourself?

      SPlattenS Offline
      SPlattenS Offline
      SPlatten
      wrote on last edited by
      #7

      @J-Hilk , will take a look now.

      Kind Regards,
      Sy

      1 Reply Last reply
      0
      • J.HilkJ J.Hilk

        @SPlatten have you considered checking the auto generated "ui_class.h"file and simply taking the c++ code of your tabs from there and than using that code to create them yourself?

        SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by
        #8

        @J-Hilk , looking at the header ui_ws_status_page.h, this contains the class Ui_WsStatusPage which does have everything I need, however I've just searched the file system for Ui_WsStatusPage and there are no references to it, how to I use it?

        Kind Regards,
        Sy

        JonBJ 1 Reply Last reply
        0
        • SPlattenS SPlatten

          @J-Hilk , looking at the header ui_ws_status_page.h, this contains the class Ui_WsStatusPage which does have everything I need, however I've just searched the file system for Ui_WsStatusPage and there are no references to it, how to I use it?

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #9

          @SPlatten
          Please just look (carefully) at the code. I said before

          Whatever, the answer lies in looking in tabwidget.h and/or ui_tabwidget.h since those are the entire code.

          If you don't follow put in breakpoints and step through, there is no magic and nothing external here.

          SPlattenS 1 Reply Last reply
          0
          • JonBJ JonB

            @SPlatten
            Please just look (carefully) at the code. I said before

            Whatever, the answer lies in looking in tabwidget.h and/or ui_tabwidget.h since those are the entire code.

            If you don't follow put in breakpoints and step through, there is no magic and nothing external here.

            SPlattenS Offline
            SPlattenS Offline
            SPlatten
            wrote on last edited by
            #10

            @JonB , looking at the class as I said it does contain everything I need but I cannot find Ui_WsStatusPage (Class name) anywhere else in the file system or source code except in the header file itself.

            Kind Regards,
            Sy

            JonBJ 1 Reply Last reply
            0
            • SPlattenS SPlatten

              @JonB , looking at the class as I said it does contain everything I need but I cannot find Ui_WsStatusPage (Class name) anywhere else in the file system or source code except in the header file itself.

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by JonB
              #11

              @SPlatten
              So put a breakpoint on its constructor, and on setupUi()..... If you are right, they will never be called and you can ignore all their code.

              SPlattenS 1 Reply Last reply
              0
              • JonBJ JonB

                @SPlatten
                So put a breakpoint on its constructor, and on setupUi()..... If you are right, they will never be called and you can ignore all their code.

                SPlattenS Offline
                SPlattenS Offline
                SPlatten
                wrote on last edited by
                #12

                @JonB said in How to get Widget from UI file:

                I wish I could, but the project is built with cmake, not in Qt Creator, I can only run it in the console.

                Kind Regards,
                Sy

                JKSHJ JonBJ 2 Replies Last reply
                0
                • SPlattenS SPlatten

                  @JonB said in How to get Widget from UI file:

                  I wish I could, but the project is built with cmake, not in Qt Creator, I can only run it in the console.

                  JKSHJ Offline
                  JKSHJ Offline
                  JKSH
                  Moderators
                  wrote on last edited by
                  #13

                  @SPlatten said in How to get Widget from UI file:

                  I wish I could, but the project is built with cmake, not in Qt Creator, I can only run it in the console.

                  You can use Qt Creator to open a CMakeLists.txt project and run console applications.

                  Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

                  1 Reply Last reply
                  1
                  • SPlattenS SPlatten

                    @JonB said in How to get Widget from UI file:

                    I wish I could, but the project is built with cmake, not in Qt Creator, I can only run it in the console.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #14

                    @SPlatten
                    Then edit the code to put in a qDebug(), or a message box, or a print to file, or whatever....

                    Or, comment out that class, since you have said it is never used, and recompile.

                    SPlattenS 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @SPlatten
                      Then edit the code to put in a qDebug(), or a message box, or a print to file, or whatever....

                      Or, comment out that class, since you have said it is never used, and recompile.

                      SPlattenS Offline
                      SPlattenS Offline
                      SPlatten
                      wrote on last edited by
                      #15

                      @JonB , can I edit the content of ui_ws_status_page.h and add to it?

                      Kind Regards,
                      Sy

                      jsulmJ 1 Reply Last reply
                      0
                      • SPlattenS SPlatten

                        @JonB , can I edit the content of ui_ws_status_page.h and add to it?

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

                        @SPlatten Your changes will be overridden next time this header file is generated

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

                        SPlattenS 1 Reply Last reply
                        1
                        • jsulmJ jsulm

                          @SPlatten Your changes will be overridden next time this header file is generated

                          SPlattenS Offline
                          SPlattenS Offline
                          SPlatten
                          wrote on last edited by
                          #17

                          @jsulm , ok, so how can I fix the tabs in the UI to do what I want? I'm done this without the tabs in the UI but its to be a job to rip it all apart. Right now I need to call setTabBar after all the initialisation has completed with the tabs added, but I cannot all setTTabBar outside of the class as its a protected method.

                          Kind Regards,
                          Sy

                          JonBJ 1 Reply Last reply
                          0
                          • SPlattenS SPlatten

                            @jsulm , ok, so how can I fix the tabs in the UI to do what I want? I'm done this without the tabs in the UI but its to be a job to rip it all apart. Right now I need to call setTabBar after all the initialisation has completed with the tabs added, but I cannot all setTTabBar outside of the class as its a protected method.

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #18

                            @SPlatten
                            Outside of what class? I really don't know your code. If you need to access a protected method then subclass and you can do what you like?

                            SPlattenS 1 Reply Last reply
                            0
                            • JonBJ JonB

                              @SPlatten
                              Outside of what class? I really don't know your code. If you need to access a protected method then subclass and you can do what you like?

                              SPlattenS Offline
                              SPlattenS Offline
                              SPlatten
                              wrote on last edited by
                              #19

                              @JonB , its really not my code, I'm just trying to make it work and failing.

                              Kind Regards,
                              Sy

                              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