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. Widgets inside another widget should resize
Forum Updated to NodeBB v4.3 + New Features

Widgets inside another widget should resize

Scheduled Pinned Locked Moved Unsolved General and Desktop
11 Posts 6 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.
  • Pradeep KumarP Offline
    Pradeep KumarP Offline
    Pradeep Kumar
    wrote on last edited by
    #1

    HI,

    I have one widget and added to QVBoxLayout
    and one more widget set has parent .

    m_widget = new QWidget;
        m_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    
        m_anotherwidget = new CConfigurePTZ(m_widget);
        m_anotherwidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
    

    when i expand window m_widget is expanding, but the m_anotherwidget is not expanding.

    How to achieve this .

    Thanks,

    Pradeep Kumar
    Qt,QML Developer

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mostefa
      wrote on last edited by
      #2

      Hi @Pradeep-Kumar

      Try to add a layout to your m_widget, i think that this is the problem.

      1 Reply Last reply
      3
      • Pradeep KumarP Offline
        Pradeep KumarP Offline
        Pradeep Kumar
        wrote on last edited by
        #3

        Hi,

        i tried adding QHBoxLayout to m_widget, still not expanding

        m_HBoxLayout = new QHBoxLayout;
        m_HBoxLayout->addWidget(m_Widget);
        

        still m_anotherwidget is not expanding.

        Pradeep Kumar
        Qt,QML Developer

        J.HilkJ 1 Reply Last reply
        0
        • Pradeep KumarP Pradeep Kumar

          Hi,

          i tried adding QHBoxLayout to m_widget, still not expanding

          m_HBoxLayout = new QHBoxLayout;
          m_HBoxLayout->addWidget(m_Widget);
          

          still m_anotherwidget is not expanding.

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

          @Pradeep-Kumar
          close, but you have to define m_anotherwidget as part of your m_HBoxLayout.
          Otherwise you have just 2 unrelated widgets lying ontop of each other.


          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.

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

            You have to set your layout on a widget for it to do something.

            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
            0
            • M Offline
              M Offline
              mostefa
              wrote on last edited by
              #6

              as @SGaist said

              you have to add

              m_widget->setLayout(m_HBoxLayout);

              1 Reply Last reply
              0
              • Pradeep KumarP Offline
                Pradeep KumarP Offline
                Pradeep Kumar
                wrote on last edited by
                #7
                ```
                

                m_widget = new QWidget;
                m_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

                m_anotherwidget = new CConfigurePTZ(m_widget);
                m_anotherwidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
                

                m_HBoxLayout = new QHBoxLayout;
                m_HBoxLayout->addWidget(m_Widget);

                i have a gridlayout and my hboxlayout setting it to vboxlayout.

                m_pQVBoxLayout->addLayout(m_GridLayout);
                m_pQVBoxLayout->addLayout(m_HBoxLayout);
                this->setLayout(m_VBoxLayout);

                
                how can i modify hboxlayout?.
                
                Thanks,

                Pradeep Kumar
                Qt,QML Developer

                jsulmJ 1 Reply Last reply
                0
                • Pradeep KumarP Offline
                  Pradeep KumarP Offline
                  Pradeep Kumar
                  wrote on last edited by
                  #8

                  can anyone suggest how this can be achieved?.

                  Pradeep Kumar
                  Qt,QML Developer

                  1 Reply Last reply
                  0
                  • Pradeep KumarP Pradeep Kumar
                    ```
                    

                    m_widget = new QWidget;
                    m_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

                    m_anotherwidget = new CConfigurePTZ(m_widget);
                    m_anotherwidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
                    

                    m_HBoxLayout = new QHBoxLayout;
                    m_HBoxLayout->addWidget(m_Widget);

                    i have a gridlayout and my hboxlayout setting it to vboxlayout.

                    m_pQVBoxLayout->addLayout(m_GridLayout);
                    m_pQVBoxLayout->addLayout(m_HBoxLayout);
                    this->setLayout(m_VBoxLayout);

                    
                    how can i modify hboxlayout?.
                    
                    Thanks,
                    jsulmJ Offline
                    jsulmJ Offline
                    jsulm
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @Pradeep-Kumar said in Widgets inside another widget should resize:

                    how can i modify hboxlayout?

                    What do you want to modify in hboxlayout?
                    You should really read about layouts in Qt.

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

                    1 Reply Last reply
                    0
                    • VRoninV Offline
                      VRoninV Offline
                      VRonin
                      wrote on last edited by VRonin
                      #10

                      You are confusing which widget should go in the layout and which widget the layout applies to

                      m_widget = new QWidget;
                      m_widget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
                      
                      m_anotherwidget = new CConfigurePTZ(m_widget);
                      //m_anotherwidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
                      
                      QHBoxLayout* widgetLay = new QHBoxLayout(m_widget);
                      widgetLay->addWidget(m_anotherwidget);
                      
                      m_VBoxLayout->addWidget(m_widget);
                      this->setLayout(m_VBoxLayout);
                      

                      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                      ~Napoleon Bonaparte

                      On a crusade to banish setIndexWidget() from the holy land of Qt

                      1 Reply Last reply
                      4
                      • Pradeep KumarP Offline
                        Pradeep KumarP Offline
                        Pradeep Kumar
                        wrote on last edited by
                        #11

                        Hi,

                        Thanks guys.

                        Pradeep Kumar
                        Qt,QML Developer

                        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