Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. Is it possible to know the adress of all widgets in a QSplitter ?
QtWS25 Last Chance

Is it possible to know the adress of all widgets in a QSplitter ?

Scheduled Pinned Locked Moved Solved Qt Creator and other tools
8 Posts 2 Posters 1.0k 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.
  • B Offline
    B Offline
    bozo6919
    wrote on last edited by
    #1

    All is in the title.

    An example :

        QWidget widget;
        QVBoxLayout *layout = new QVBoxLayout;
        QWidget *first = createQWidget();
        QWidget *second = createQWidget();
        QSplitter *split = new QSplitter;
    
        split->addWidget(first);
        split->addWidget(second);
        layout->addWidget(split);
        widget.setLayout(layout);
    

    And now in another function, I have simply split and I want to obtain first and second. Is it possible?

    Sorry for my English ^^'

    1 Reply Last reply
    0
    • sierdzioS sierdzio

      @bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:

      If I know just the QWidget Second, I can search the split with second->parent() ?

      Yes. If QSplitter assigns itself as parent of the widgets it splits, it should work.

      B Offline
      B Offline
      bozo6919
      wrote on last edited by bozo6919
      #7

      Okei, thanks :)

      How put the topic in solved ? ^^'

      And I have another question, I say it here or I create a new topic?

      Sorry for my English ^^'

      sierdzioS 1 Reply Last reply
      0
      • sierdzioS Offline
        sierdzioS Offline
        sierdzio
        Moderators
        wrote on last edited by
        #2

        split->children() should contain your widgets. You can give them objectName to make searching even easier.

        (Z(:^

        B 1 Reply Last reply
        1
        • sierdzioS sierdzio

          split->children() should contain your widgets. You can give them objectName to make searching even easier.

          B Offline
          B Offline
          bozo6919
          wrote on last edited by bozo6919
          #3

          @sierdzio I can do simply like this :

              QObjectList widgetList = split->children();
              QWidget *saveWidget = (QWidget *)widgetList[0];
              QWidget *delWidget = (QWidget *)widgetList[1];
          

          Or something wrong ?

          Sorry for my English ^^'

          sierdzioS 1 Reply Last reply
          0
          • B bozo6919

            @sierdzio I can do simply like this :

                QObjectList widgetList = split->children();
                QWidget *saveWidget = (QWidget *)widgetList[0];
                QWidget *delWidget = (QWidget *)widgetList[1];
            

            Or something wrong ?

            sierdzioS Offline
            sierdzioS Offline
            sierdzio
            Moderators
            wrote on last edited by
            #4

            @bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:

            @sierdzio I can do simply like this :

                QObjectList widgetList = split->children();
                QWidget *saveWidget = (QWidget *)widgetList[0];
                QWidget *delWidget = (QWidget *)widgetList[1];
            

            Or something wrong ?

            It is OK. I'd only recommend to check widgetList size before trying to access the list elements.

            (Z(:^

            B 1 Reply Last reply
            0
            • sierdzioS sierdzio

              @bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:

              @sierdzio I can do simply like this :

                  QObjectList widgetList = split->children();
                  QWidget *saveWidget = (QWidget *)widgetList[0];
                  QWidget *delWidget = (QWidget *)widgetList[1];
              

              Or something wrong ?

              It is OK. I'd only recommend to check widgetList size before trying to access the list elements.

              B Offline
              B Offline
              bozo6919
              wrote on last edited by
              #5

              @sierdzio Yes, thanks.
              For search parents, it's the same?

              If I know just the QWidget Second, I can search the split with second->parent() ?
              (I cannot test for the moment, I don't have my computer)

              Sorry for my English ^^'

              sierdzioS 1 Reply Last reply
              0
              • B bozo6919

                @sierdzio Yes, thanks.
                For search parents, it's the same?

                If I know just the QWidget Second, I can search the split with second->parent() ?
                (I cannot test for the moment, I don't have my computer)

                sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #6

                @bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:

                If I know just the QWidget Second, I can search the split with second->parent() ?

                Yes. If QSplitter assigns itself as parent of the widgets it splits, it should work.

                (Z(:^

                B 1 Reply Last reply
                0
                • sierdzioS sierdzio

                  @bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:

                  If I know just the QWidget Second, I can search the split with second->parent() ?

                  Yes. If QSplitter assigns itself as parent of the widgets it splits, it should work.

                  B Offline
                  B Offline
                  bozo6919
                  wrote on last edited by bozo6919
                  #7

                  Okei, thanks :)

                  How put the topic in solved ? ^^'

                  And I have another question, I say it here or I create a new topic?

                  Sorry for my English ^^'

                  sierdzioS 1 Reply Last reply
                  0
                  • B bozo6919

                    Okei, thanks :)

                    How put the topic in solved ? ^^'

                    And I have another question, I say it here or I create a new topic?

                    sierdzioS Offline
                    sierdzioS Offline
                    sierdzio
                    Moderators
                    wrote on last edited by
                    #8

                    @bozo6919 said in Is it possible to know the adress of all widgets in a QSplitter ?:

                    Okei, thanks :)

                    How put the topic in solved ? ^^'

                    Click the 3 dots to the right of the solving post, and there click on "mark as solved".

                    And I have another question, I say it here or I create a new topic?

                    Better open another topic.

                    (Z(:^

                    1 Reply Last reply
                    1

                    • Login

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