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. [Solved]Will QTabWidget::addTab() set the parent for the widget handed over as parameter?
Qt 6.11 is out! See what's new in the release blog

[Solved]Will QTabWidget::addTab() set the parent for the widget handed over as parameter?

Scheduled Pinned Locked Moved General and Desktop
8 Posts 5 Posters 7.0k 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.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I guess the title says it all. If I do this:

    @tabWidget->addTab(myParentlessWidget, "text");@

    Will "myParentlessWidget" have a parent widget set automatically?

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Yes, the QStackedWidget inside QTabWidget becomes the new parent.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        thank you Lukas

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          Add
          @
          if (myParentlessWidget->parent())
          qDebug() << "GOT A PARENT NOW!";
          @

          after your code and check the output... That should produce results faster than posting on a forum;-).

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            [quote author="Tobias Hunger" date="1330010028"]Add
            @
            if (myParentlessWidget->parent())
            qDebug() << "GOT A PARENT NOW!";
            @

            after your code and check the output... That should produce results faster than posting on a forum;-).[/quote]
            :-)
            The "Just try it" mentality is not all that wide-spread anymore, I'm afraid...

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #6

              Damn it's so simple. I feel kind of silly now for not thinking of that myself.

              1 Reply Last reply
              0
              • ? Offline
                ? Offline
                A Former User
                wrote on last edited by
                #7

                In doubt I usually just take a look at the sources. Done in a minute and I can be absolutely sure what's going on. Plus, you learn a lot about Qt and its internals.

                1 Reply Last reply
                0
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #8

                  I added a "DocNote":/doc/qt-4.8/qtabwidget.html#notes for future reference. Feel free to add those yourself, in case you have the answer of a question like this!

                  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