Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Layout problem
Qt 6.12 LTS is out! See what's new in the release blog

Layout problem

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 3 Posters 1.7k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #5

    @SPlatten said in Layout problem:

    void addButton(QAbstractButton& robjButton, const QString& crstrGroup);

    Why are you passing a reference here ? The usual way to pass QObject based class around is through pointers.

    Interested in AI ? www.idiap.ch
    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

    SPlattenS 1 Reply Last reply
    0
    • SGaistS SGaist

      @SPlatten said in Layout problem:

      void addButton(QAbstractButton& robjButton, const QString& crstrGroup);

      Why are you passing a reference here ? The usual way to pass QObject based class around is through pointers.

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

      @SGaist passing references is as good as passing a pointer with added advantages in that they are safer.

      Kind Regards,
      Sy

      1 Reply Last reply
      0
      • SPlattenS Offline
        SPlattenS Offline
        SPlatten
        wrote on last edited by SPlatten
        #7

        Still trying to figure out what is going on, I have added some debug code to my addButton function:

        void clsQtLayout::addButton(QAbstractButton* pobjButton, const QString& crstrGroup) {
            if ( pobjButton == nullptr ) {
                return;
            }
            if ( crstrGroup.isEmpty() != true ) {
                QButtonGroup* pobjBtnGrp(pobjAddGroup(crstrGroup));
                if ( pobjBtnGrp != nullptr ) {
        {qdbg() << "BEFORE: " << pobjButton->text();
        QButtonGroup* pobjCurGrp(pobjButton->group());
        if ( pobjCurGrp != nullptr ) {
        qdbg() << "CURRENT GROUP: " << pobjCurGrp;
        QList<QAbstractButton*> lstButtons(pobjCurGrp->buttons());
        qdbg() << QString("BUTTONS.length=%1 list:").arg(lstButtons.length()) << lstButtons;
        }}
                    pobjBtnGrp->addButton(pobjButton);
        {qdbg() << "AFTER: " << pobjButton->text();
        QButtonGroup* pobjCurGrp(pobjButton->group());
        if ( pobjCurGrp != nullptr ) {
        qdbg() << "CURRENT GROUP: " << pobjCurGrp;
        QList<QAbstractButton*> lstButtons(pobjCurGrp->buttons());
        qdbg() << QString("BUTTONS.length=%1 list:").arg(lstButtons.length()) << lstButtons;
        }}
                }
            }
            if ( mpobjFLO != nullptr ) {
                mpobjFLO->addWidget(pobjButton);
            }   
        }
        

        The output of from the above:

        S000000000036E000000000652T14:12:25.261DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
        BEFORE: Male
        S000000000037E000000000652T14:12:25.261DL00000121F../clsQtLayout.cpp[void clsQtLayout::addButton]
        AFTER: Male
        S000000000038E000000000652T14:12:25.262DL00000124F../clsQtLayout.cpp[void clsQtLayout::addButton]
        CURRENT GROUP: QButtonGroup(0x600000027fe0, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
        S000000000039E000000000652T14:12:25.262DL00000126F../clsQtLayout.cpp[void clsQtLayout::addButton]
        BUTTONS.length=1 list:(clsQtRadioButton(0x600001774c40, name=Male))
        S000000000040E000000000652T14:12:25.262DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
        BEFORE: Female
        S000000000041E000000000652T14:12:25.262DL00000121F../clsQtLayout.cpp[void clsQtLayout::addButton]
        AFTER: Female
        S000000000042E000000000652T14:12:25.262DL00000124F../clsQtLayout.cpp[void clsQtLayout::addButton]
        CURRENT GROUP: QButtonGroup(0x600000027fe0, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
        S000000000043E000000000652T14:12:25.262DL00000126F../clsQtLayout.cpp[void clsQtLayout::addButton]
        BUTTONS.length=2 list:(clsQtRadioButton(0x600001774c40, name=Widget: radiobutton, id: rdoM), clsQtRadioButton(0x600001774e00, name=Female))
        

        Every line output is prefixed with S the sequence number, E elapsed time, T real time, D = Debug, L = Line number, F = function which includes the file, then the debug message.

        From the output when the first button Male is Added to the group the debug output simply shows Male as it has no group, after adding Male to the group the buttons in the list shows simply clsQtRadioButton(0x60000170a180, name=Male. When the Female button is added the buttons in the group changes to clsQtRadioButton(0x60000170a180, name=Widget: radiobutton, id: rdoM), clsQtRadioButton(0x60000170c5c0, name=Female.

        From the output after the Female button is added it looks like the Male button is still present but has changed from:
        clsQtRadioButton(0x60000170a180, name=Male)
        to:
        clsQtRadioButton(0x60000170a180, name=Widget: radiobutton, id: rdoM)
        Why and is this normal?

        Kind Regards,
        Sy

        JonBJ 1 Reply Last reply
        0
        • SPlattenS SPlatten

          Still trying to figure out what is going on, I have added some debug code to my addButton function:

          void clsQtLayout::addButton(QAbstractButton* pobjButton, const QString& crstrGroup) {
              if ( pobjButton == nullptr ) {
                  return;
              }
              if ( crstrGroup.isEmpty() != true ) {
                  QButtonGroup* pobjBtnGrp(pobjAddGroup(crstrGroup));
                  if ( pobjBtnGrp != nullptr ) {
          {qdbg() << "BEFORE: " << pobjButton->text();
          QButtonGroup* pobjCurGrp(pobjButton->group());
          if ( pobjCurGrp != nullptr ) {
          qdbg() << "CURRENT GROUP: " << pobjCurGrp;
          QList<QAbstractButton*> lstButtons(pobjCurGrp->buttons());
          qdbg() << QString("BUTTONS.length=%1 list:").arg(lstButtons.length()) << lstButtons;
          }}
                      pobjBtnGrp->addButton(pobjButton);
          {qdbg() << "AFTER: " << pobjButton->text();
          QButtonGroup* pobjCurGrp(pobjButton->group());
          if ( pobjCurGrp != nullptr ) {
          qdbg() << "CURRENT GROUP: " << pobjCurGrp;
          QList<QAbstractButton*> lstButtons(pobjCurGrp->buttons());
          qdbg() << QString("BUTTONS.length=%1 list:").arg(lstButtons.length()) << lstButtons;
          }}
                  }
              }
              if ( mpobjFLO != nullptr ) {
                  mpobjFLO->addWidget(pobjButton);
              }   
          }
          

          The output of from the above:

          S000000000036E000000000652T14:12:25.261DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
          BEFORE: Male
          S000000000037E000000000652T14:12:25.261DL00000121F../clsQtLayout.cpp[void clsQtLayout::addButton]
          AFTER: Male
          S000000000038E000000000652T14:12:25.262DL00000124F../clsQtLayout.cpp[void clsQtLayout::addButton]
          CURRENT GROUP: QButtonGroup(0x600000027fe0, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
          S000000000039E000000000652T14:12:25.262DL00000126F../clsQtLayout.cpp[void clsQtLayout::addButton]
          BUTTONS.length=1 list:(clsQtRadioButton(0x600001774c40, name=Male))
          S000000000040E000000000652T14:12:25.262DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
          BEFORE: Female
          S000000000041E000000000652T14:12:25.262DL00000121F../clsQtLayout.cpp[void clsQtLayout::addButton]
          AFTER: Female
          S000000000042E000000000652T14:12:25.262DL00000124F../clsQtLayout.cpp[void clsQtLayout::addButton]
          CURRENT GROUP: QButtonGroup(0x600000027fe0, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
          S000000000043E000000000652T14:12:25.262DL00000126F../clsQtLayout.cpp[void clsQtLayout::addButton]
          BUTTONS.length=2 list:(clsQtRadioButton(0x600001774c40, name=Widget: radiobutton, id: rdoM), clsQtRadioButton(0x600001774e00, name=Female))
          

          Every line output is prefixed with S the sequence number, E elapsed time, T real time, D = Debug, L = Line number, F = function which includes the file, then the debug message.

          From the output when the first button Male is Added to the group the debug output simply shows Male as it has no group, after adding Male to the group the buttons in the list shows simply clsQtRadioButton(0x60000170a180, name=Male. When the Female button is added the buttons in the group changes to clsQtRadioButton(0x60000170a180, name=Widget: radiobutton, id: rdoM), clsQtRadioButton(0x60000170c5c0, name=Female.

          From the output after the Female button is added it looks like the Male button is still present but has changed from:
          clsQtRadioButton(0x60000170a180, name=Male)
          to:
          clsQtRadioButton(0x60000170a180, name=Widget: radiobutton, id: rdoM)
          Why and is this normal?

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

          @SPlatten
          Bear in mind I have never used a QButtonGroup! Or if I have I didn't look at it, it just worked.

          A quick glance at https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qbuttongroup.cpp.html, I don't spot anything there changing object names.....

          I assume you would know if your code ever generates an object name like Widget: radiobutton, id: rdoM.

          Now that you say you (seem to) have a object name being changed (which I did not expect), use signal QObject::objectNameChanged to monitor when that happens.

          Otherwise I guess it's possible the debug display of QButtonGroup just happens to output more than one button in the format you see, I don't know. (If you then remove the female button, does display output with just male in it revert to how it was originally or remain in the "changed" form?)

          You could examine what is in your QButtonGroup::buttons()[0] in more detail to see what is really going there, compared against the QButtonGroup::buttons()[1].

          SPlattenS JonBJ 2 Replies Last reply
          0
          • JonBJ JonB

            @SPlatten
            Bear in mind I have never used a QButtonGroup! Or if I have I didn't look at it, it just worked.

            A quick glance at https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qbuttongroup.cpp.html, I don't spot anything there changing object names.....

            I assume you would know if your code ever generates an object name like Widget: radiobutton, id: rdoM.

            Now that you say you (seem to) have a object name being changed (which I did not expect), use signal QObject::objectNameChanged to monitor when that happens.

            Otherwise I guess it's possible the debug display of QButtonGroup just happens to output more than one button in the format you see, I don't know. (If you then remove the female button, does display output with just male in it revert to how it was originally or remain in the "changed" form?)

            You could examine what is in your QButtonGroup::buttons()[0] in more detail to see what is really going there, compared against the QButtonGroup::buttons()[1].

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

            @JonB , thank you, I modified the function:

            void clsQtLayout::addButton(QAbstractButton* pobjButton, const QString& crstrGroup) {
                if ( pobjButton == nullptr ) {
                    return;
                }
                if ( crstrGroup.isEmpty() != true ) {
                    QButtonGroup* pobjBtnGrp(pobjAddGroup(crstrGroup));
                    if ( pobjBtnGrp != nullptr ) {
            {qdbg() << "BEFORE: " << pobjButton->text();
            QButtonGroup* pobjCurGrp(pobjButton->group());
            if ( pobjCurGrp != nullptr ) {
            qdbg() << "CURRENT GROUP: " << pobjCurGrp;
            QList<QAbstractButton*> lstButtons(pobjCurGrp->buttons());
            qdbg() << QString("BUTTONS.length=%1 list:").arg(lstButtons.length()) << lstButtons;
            qdbg() << "Button[0]: " << lstButtons[0];
            }}
                        pobjBtnGrp->addButton(pobjButton);
            {qdbg() << "AFTER: " << pobjButton->text();
            QButtonGroup* pobjCurGrp(pobjButton->group());
            if ( pobjCurGrp != nullptr ) {
            qdbg() << "CURRENT GROUP: " << pobjCurGrp;
            QList<QAbstractButton*> lstButtons(pobjCurGrp->buttons());
            qdbg() << QString("BUTTONS.length=%1 list:").arg(lstButtons.length()) << lstButtons;
            qdbg() << "Button[0]: " << lstButtons[0];
            if ( lstButtons.length() > 1 ) {
            qdbg() << "Button[1]: " << lstButtons[1];
            }
            }}
                    }
                }
                if ( mpobjFLO != nullptr ) {
                    mpobjFLO->addWidget(pobjButton);
                }   
            }
            

            The output is now:

            S000000000036E000000000719T14:24:00.461DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
            BEFORE: Male
            S000000000037E000000000719T14:24:00.461DL00000122F../clsQtLayout.cpp[void clsQtLayout::addButton]
            AFTER: Male
            S000000000038E000000000719T14:24:00.461DL00000125F../clsQtLayout.cpp[void clsQtLayout::addButton]
            CURRENT GROUP: QButtonGroup(0x600000028f50, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
            S000000000039E000000000719T14:24:00.461DL00000127F../clsQtLayout.cpp[void clsQtLayout::addButton]
            BUTTONS.length=1 list:(clsQtRadioButton(0x60000176f140, name=Male))
            S000000000040E000000009972T14:24:09.714DL00000128F../clsQtLayout.cpp[void clsQtLayout::addButton]
            Button[0]: clsQtRadioButton(0x60000176f140, name=Male)
            S000000000041E000000012687T14:24:12.429DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
            BEFORE: Female
            S000000000042E000000012687T14:24:12.429DL00000122F../clsQtLayout.cpp[void clsQtLayout::addButton]
            AFTER: Female
            S000000000043E000000012687T14:24:12.429DL00000125F../clsQtLayout.cpp[void clsQtLayout::addButton]
            CURRENT GROUP: QButtonGroup(0x600000028f50, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
            S000000000044E000000012687T14:24:12.429DL00000127F../clsQtLayout.cpp[void clsQtLayout::addButton]
            BUTTONS.length=2 list:(clsQtRadioButton(0x60000176f140, name=Widget: radiobutton, id: rdoM), clsQtRadioButton(0x600001756d00, name=Female))
            S000000000045E000000015192T14:24:14.934DL00000128F../clsQtLayout.cpp[void clsQtLayout::addButton]
            Button[0]: clsQtRadioButton(0x60000176f140, name=Widget: radiobutton, id: rdoM)
            S000000000046E000000018239T14:24:17.981DL00000130F../clsQtLayout.cpp[void clsQtLayout::addButton]
            Button[1]: clsQtRadioButton(0x600001756d00, name=Female)
            

            Kind Regards,
            Sy

            1 Reply Last reply
            0
            • JonBJ JonB

              @SPlatten
              Bear in mind I have never used a QButtonGroup! Or if I have I didn't look at it, it just worked.

              A quick glance at https://code.woboq.org/qt5/qtbase/src/widgets/widgets/qbuttongroup.cpp.html, I don't spot anything there changing object names.....

              I assume you would know if your code ever generates an object name like Widget: radiobutton, id: rdoM.

              Now that you say you (seem to) have a object name being changed (which I did not expect), use signal QObject::objectNameChanged to monitor when that happens.

              Otherwise I guess it's possible the debug display of QButtonGroup just happens to output more than one button in the format you see, I don't know. (If you then remove the female button, does display output with just male in it revert to how it was originally or remain in the "changed" form?)

              You could examine what is in your QButtonGroup::buttons()[0] in more detail to see what is really going there, compared against the QButtonGroup::buttons()[1].

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

              @JonB said in Layout problem:

              I assume you would know if your code ever generates an object name like Widget: radiobutton, id: rdoM.

              ^^^^^ ?????

              Now that you say you (seem to) have a object name being changed (which I did not expect), use signal QObject::objectNameChanged to monitor when that happens.

              You could examine what is in your QButtonGroup::buttons()[0] in more detail --- go find out in code what type it really is.

              I think I'm seeing clsQtRadioButton(0x60000176f140 throughout for the Male one, so the object instance does not seem to be changing.

              SPlattenS 2 Replies Last reply
              0
              • JonBJ JonB

                @JonB said in Layout problem:

                I assume you would know if your code ever generates an object name like Widget: radiobutton, id: rdoM.

                ^^^^^ ?????

                Now that you say you (seem to) have a object name being changed (which I did not expect), use signal QObject::objectNameChanged to monitor when that happens.

                You could examine what is in your QButtonGroup::buttons()[0] in more detail --- go find out in code what type it really is.

                I think I'm seeing clsQtRadioButton(0x60000176f140 throughout for the Male one, so the object instance does not seem to be changing.

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

                @JonB , I've just modified my radio button derived class adding:

                QObject::connect(this, &QObject::objectNameChanged, [](const QString& crstrName) {
                    qdbg() << crstrName;
                });
                

                Will report back after running.

                Kind Regards,
                Sy

                1 Reply Last reply
                0
                • JonBJ JonB

                  @JonB said in Layout problem:

                  I assume you would know if your code ever generates an object name like Widget: radiobutton, id: rdoM.

                  ^^^^^ ?????

                  Now that you say you (seem to) have a object name being changed (which I did not expect), use signal QObject::objectNameChanged to monitor when that happens.

                  You could examine what is in your QButtonGroup::buttons()[0] in more detail --- go find out in code what type it really is.

                  I think I'm seeing clsQtRadioButton(0x60000176f140 throughout for the Male one, so the object instance does not seem to be changing.

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

                  @JonB , fixed another bug which prevents renaming of object already assigned a name:

                  void clsXMLnode::setObjName(QObject& robjObject, const QString& crstrName) {
                      if ( crstrName.isEmpty() != true ) {
                          QString strCurrent(robjObject.objectName());
                          if ( strCurrent.isEmpty() != true ) {
                              qdbg() << "Current name: " << strCurrent << ", Tried to change to: " << crstrName;
                          } else {
                      //Set the object name
                              robjObject.setObjectName(crstrName);
                          }
                      }
                  }
                  

                  Now the output is:

                  S000000000044E000000000659T14:37:04.373DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  BEFORE: Male
                  S000000000045E000000000659T14:37:04.373DL00000122F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  AFTER: Male
                  S000000000046E000000000659T14:37:04.373DL00000125F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  CURRENT GROUP: QButtonGroup(0x60000002ac70, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
                  S000000000047E000000000659T14:37:04.373DL00000127F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  BUTTONS.length=1 list:(clsQtRadioButton(0x600001723c00, name=Male))
                  S000000000048E000000000659T14:37:04.373DL00000128F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  Button[0]: clsQtRadioButton(0x600001723c00, name=Male)
                  S000000000049E000000000659T14:37:04.373DL00003730F../clsMainWnd.cpp[static void clsXMLnode::setObjName]
                  Current name: Male
                  S000000000050E000000000659T14:37:04.373DL00000051F../clsQtRadionButton.cpp[auto clsQtRadioButton::clsQtRadioButton]
                  Female
                  S000000000051E000000000659T14:37:04.373DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  BEFORE: Female
                  S000000000052E000000000659T14:37:04.373DL00000122F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  AFTER: Female
                  S000000000053E000000000659T14:37:04.373DL00000125F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  CURRENT GROUP: QButtonGroup(0x60000002ac70, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
                  S000000000054E000000000659T14:37:04.373DL00000127F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  BUTTONS.length=2 list:(clsQtRadioButton(0x600001723c00, name=Male), clsQtRadioButton(0x60000170f340, name=Female))
                  S000000000055E000000000660T14:37:04.373DL00000128F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  Button[0]: clsQtRadioButton(0x600001723c00, name=Male)
                  S000000000056E000000000660T14:37:04.373DL00000130F../clsQtLayout.cpp[void clsQtLayout::addButton]
                  Button[1]: clsQtRadioButton(0x60000170f340, name=Female)
                  

                  Kind Regards,
                  Sy

                  SPlattenS 1 Reply Last reply
                  0
                  • SPlattenS SPlatten

                    @JonB , fixed another bug which prevents renaming of object already assigned a name:

                    void clsXMLnode::setObjName(QObject& robjObject, const QString& crstrName) {
                        if ( crstrName.isEmpty() != true ) {
                            QString strCurrent(robjObject.objectName());
                            if ( strCurrent.isEmpty() != true ) {
                                qdbg() << "Current name: " << strCurrent << ", Tried to change to: " << crstrName;
                            } else {
                        //Set the object name
                                robjObject.setObjectName(crstrName);
                            }
                        }
                    }
                    

                    Now the output is:

                    S000000000044E000000000659T14:37:04.373DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    BEFORE: Male
                    S000000000045E000000000659T14:37:04.373DL00000122F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    AFTER: Male
                    S000000000046E000000000659T14:37:04.373DL00000125F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    CURRENT GROUP: QButtonGroup(0x60000002ac70, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
                    S000000000047E000000000659T14:37:04.373DL00000127F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    BUTTONS.length=1 list:(clsQtRadioButton(0x600001723c00, name=Male))
                    S000000000048E000000000659T14:37:04.373DL00000128F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    Button[0]: clsQtRadioButton(0x600001723c00, name=Male)
                    S000000000049E000000000659T14:37:04.373DL00003730F../clsMainWnd.cpp[static void clsXMLnode::setObjName]
                    Current name: Male
                    S000000000050E000000000659T14:37:04.373DL00000051F../clsQtRadionButton.cpp[auto clsQtRadioButton::clsQtRadioButton]
                    Female
                    S000000000051E000000000659T14:37:04.373DL00000113F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    BEFORE: Female
                    S000000000052E000000000659T14:37:04.373DL00000122F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    AFTER: Female
                    S000000000053E000000000659T14:37:04.373DL00000125F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    CURRENT GROUP: QButtonGroup(0x60000002ac70, name = Layout: form, ID: rdoLO, QButtonGroup: enSEX)
                    S000000000054E000000000659T14:37:04.373DL00000127F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    BUTTONS.length=2 list:(clsQtRadioButton(0x600001723c00, name=Male), clsQtRadioButton(0x60000170f340, name=Female))
                    S000000000055E000000000660T14:37:04.373DL00000128F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    Button[0]: clsQtRadioButton(0x600001723c00, name=Male)
                    S000000000056E000000000660T14:37:04.373DL00000130F../clsQtLayout.cpp[void clsQtLayout::addButton]
                    Button[1]: clsQtRadioButton(0x60000170f340, name=Female)
                    
                    SPlattenS Offline
                    SPlattenS Offline
                    SPlatten
                    wrote on last edited by SPlatten
                    #13

                    Finally, fixed!
                    Screenshot 2021-11-27 at 18.07.23.png

                    When processing the widgets, if the type of widget is a layout then the actual widget connected to the parent layout is the scroll area not the layout itself.

                    I then had another issue which was to take the widgets that are children of any groups in the layout and adding these to the layouts.

                    Next issue which I'm now going to fix is the individual row height of the children so that have the correct height in the layout.

                    Final demo with row height fixed:
                    Screenshot 2021-11-27 at 19.01.20.png

                    From XML:

                    	<layout id="rdoLO" height="56" hspacing="0" type="form"
                    			vspacing="0" properties="QLayout { background-color:#ffaaaa;}">
                    		<buttongroup id="enSEX">
                    			<radiobutton id="rdoM" height="28" text="Male" default="true" 
                    						 position="0,0"/>
                    			<radiobutton id="rdoF" height="28" text="Female" position="1,0"/>
                    		</buttongroup>
                    	</layout>
                    

                    Kind Regards,
                    Sy

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #14

                      @SPlatten said in Layout problem:

                      clsQtLayout

                      Please reconsider the naming of your class. They make things harder to understand for no benefits. Your clsQtLayout is in fact a QWidget. The Qt layout classes are not QWidgets. This name is confusing at best.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      2

                      • Login

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