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. QTabWidget : how to get widget ui made with designer
Forum Updated to NodeBB v4.3 + New Features

QTabWidget : how to get widget ui made with designer

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 975 Views 1 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.
  • O Offline
    O Offline
    orio
    wrote on last edited by
    #3

    @jsulm said in QTabWidget : how to get widget ui made with designer:

    ui->widgetName

    ui->widgetName is the QTabWidget, it has widgets inside it.
    i can get Widget * to them .

    say one of this widgets has QPushButton named pushButton_

    how can i get it

    jsulmJ 2 Replies Last reply
    0
    • O orio

      @jsulm said in QTabWidget : how to get widget ui made with designer:

      ui->widgetName

      ui->widgetName is the QTabWidget, it has widgets inside it.
      i can get Widget * to them .

      say one of this widgets has QPushButton named pushButton_

      how can i get it

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #4
      This post is deleted!
      1 Reply Last reply
      0
      • O orio

        @jsulm said in QTabWidget : how to get widget ui made with designer:

        ui->widgetName

        ui->widgetName is the QTabWidget, it has widgets inside it.
        i can get Widget * to them .

        say one of this widgets has QPushButton named pushButton_

        how can i get it

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

        @orio said in QTabWidget : how to get widget ui made with designer:

        how can i get it

        https://doc.qt.io/qt-5/qobject.html#findChild

        O 1 Reply Last reply
        0
        • O Offline
          O Offline
          orio
          wrote on last edited by
          #6
          This post is deleted!
          1 Reply Last reply
          0
          • jsulmJ jsulm

            @orio said in QTabWidget : how to get widget ui made with designer:

            how can i get it

            https://doc.qt.io/qt-5/qobject.html#findChild

            O Offline
            O Offline
            orio
            wrote on last edited by
            #7

            @jsulm

            so as i stated in my post , meta object find child is the only option.

            now i need to find child for each inner button / lineedit and save a pointer to it .
            it was bad idea to design those widgets in designer

            jsulmJ 1 Reply Last reply
            0
            • O orio

              @jsulm

              so as i stated in my post , meta object find child is the only option.

              now i need to find child for each inner button / lineedit and save a pointer to it .
              it was bad idea to design those widgets in designer

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

              @orio But why do you need access to these sub-widgets outside of the container widget? It is bad design to make internal details known to outside world. What you can do instead: add signals to the container widget which are emitted when sub-widgets trigger some actions and connect to these signals where you need to. This way other parts of your application do not need to know anything about ui details in other widgets.
              For example: connect clicked() signal from ui->pushButton_ to a signal in the widget which contains this button, so other parts of your app will connect to that signal instead of having to know about sub-widgets to connect to.

              1 Reply Last reply
              1
              • O Offline
                O Offline
                orio
                wrote on last edited by
                #9

                but i dont have accses to ui... again

                JonBJ jsulmJ 2 Replies Last reply
                0
                • O orio

                  but i dont have accses to ui... again

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

                  @orio
                  Hi. Not 100% on what you are saying, but to answer simply.

                  If, for whatever reason, you do not have access to direct variables referencing your widgets (the ui->.... stuff you would end up after running uic on the Designer's .ui file), then all you have is QObject::findChild<>() and QObject::findChildren<>(), run from whichever widget ancestor you want to descend from (top-level at least to start with). With findChlidren<>() you can enumerate all widgets, so for example you can get at " each inner button / lineedit and save a pointer to it " in one go.

                  1 Reply Last reply
                  1
                  • O orio

                    but i dont have accses to ui... again

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

                    @orio said in QTabWidget : how to get widget ui made with designer:

                    but i dont have accses to ui... again

                    Of course you have - in the widget where the sub widgets are.
                    If you create a widget in QtDesigner and put some widgets (like buttons) on it then you can access those sub widgets via ui->objectName...

                    1 Reply Last reply
                    1
                    • S Offline
                      S Offline
                      SimonSchroeder
                      wrote on last edited by
                      #12

                      I guess there are two different ways of combining the widgets inside the QTabWidget. Let's get it sorted out, which you are using. Nevertheless, for both ways there have been the correct answers already.

                      1. You just have a single ui file for everything. I.e. in your ui file you have the QTabWidget, but also the subwidgets. In this case, as already mentioned, you can just access the buttons, etc. directly through ui->objectName.

                      2. You have one ui file for the QTabWidget and one ui file for each subwidget. Somehow (I have never tried that) inside the Designer you put the ui files of the subwidgets into the QTabWidget. @jsulm already suggested that you connect the signal of the button to the widget itself. There is a way directly inside the designer to do just that. So, inside the ui file of the subwidget you do all the connections and have a bunch of new signals in your subwidget. You'll be able to access these from your C++ code then.

                      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