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. My layout doesn't work
Forum Updated to NodeBB v4.3 + New Features

My layout doesn't work

Scheduled Pinned Locked Moved General and Desktop
5 Posts 3 Posters 1.2k 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.
  • M Offline
    M Offline
    mant
    wrote on last edited by
    #1

    Hi everyone. I'm creating a layout for my app.
    I want the two widget to be displayed on the left and the RenderWidget be on the right.
    Here is my code but the RenderWidget is not displayed.

    @MainUI::MainUI()
    {
    m_ObjectListWidget = new QListWidget;
    m_PhysicsConfModel = new QStandardItemModel(3, 2, this);
    m_PhysicsConfWidget = new QTableView;
    m_RenderWidget = new QWidget;
    m_InfoWidget = new QWidget;
    m_MainWidget = new QWidget;

    m_HBoxLayout = new QHBoxLayout;
    m_VBoxLayout = new QVBoxLayout;
    
    m_RenderWidget->setAttribute(Qt::WA_PaintOnScreen);
    
    m_PhysicsConfWidget->setModel(m_PhysicsConfModel);
    
    m_VBoxLayout->addWidget(m_PhysicsConfWidget);
    m_VBoxLayout->addWidget(m_ObjectListWidget);
    
    m_InfoWidget->setLayout(m_VBoxLayout);
    
    m_HBoxLayout->addWidget(m_InfoWidget);
    m_HBoxLayout->addWidget(m_RenderWidget);
    
    m_MainWidget->setLayout(m_HBoxLayout);
    
    resize(800, 600);
    
    setCentralWidget(m_MainWidget);
    

    }@

    !http://s30.postimg.org/j0wynmckx/image.png(no image)!

    I tried commenting out the line m_InfoWidget->setLayout(m_VBoxLayout);
    which made the InfoWidget be an empty Widget and it worked like this:

    !http://s18.postimg.org/qcyp06xi1/image.png(no image)!

    But I can not add two widgets to the InfoWidget on the left and display it with a QVBoxLayout. Anyone can help me to fix this?
    I'm using Qt 4.8.6 with CodeBlocks (MinGW) on an XP 32bit.
    Thank you.

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

      Hi,

      Does something like:
      @
      m_ObjectListWidget = new QListWidget;
      m_PhysicsConfWidget = new QTableView;
      m_RenderWidget = new QWidget;
      m_MainWidget = new QWidget;

      m_VBoxLayout = new QVBoxLayout;
      m_VBoxLayout->addWidget(m_PhysicsConfWidget);
      m_VBoxLayout->addWidget(m_ObjectListWidget);
      
      m_HBoxLayout = new QHBoxLayout(m_MainWidget);
      m_HBoxLayout->addLayout(m_VBoxLayout);
      m_HBoxLayout->addWidget(m_RenderWidget);
      
      setCentralWidget(m_MainWidget);
      

      @

      work ?

      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
        mant
        wrote on last edited by
        #3

        Thank you but the RenderWidget is still not displayed
        !http://s29.postimg.org/cfcapd21z/image.png(no image)!

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mant
          wrote on last edited by
          #4

          Even if I remove the renderer and add a empty widget the result is still the same as picture 1.
          @MainUI::MainUI()
          {
          m_ObjectListWidget = new QListWidget;
          m_PhysicsConfModel = new QStandardItemModel(3, 2, this);
          m_PhysicsConfWidget = new QTableView;
          m_RenderWidget = new QWidget;
          m_InfoWidget = new QWidget;
          m_MainWidget = new QWidget;

          m_HBoxLayout = new QHBoxLayout;
          m_VBoxLayout = new QVBoxLayout;
          
          m_RenderWidget->setAttribute(Qt::WA_PaintOnScreen);
          
          m_PhysicsConfWidget->setModel(m_PhysicsConfModel);
          
          m_VBoxLayout->addWidget(m_PhysicsConfWidget);
          m_VBoxLayout->addWidget(m_ObjectListWidget);
          
          m_InfoWidget->setLayout(m_VBoxLayout);
          
          QWidget* x = new QWidget;
          
          m_HBoxLayout->addWidget(m_InfoWidget);
          m_HBoxLayout->addWidget(x);
          
          m_MainWidget->setLayout(m_HBoxLayout);
          
          resize(800, 600);
          
          setCentralWidget(m_MainWidget);
          

          }@

          !http://s30.postimg.org/j0wynmckx/image.png(no image)!

          1 Reply Last reply
          0
          • R Offline
            R Offline
            Rondog
            wrote on last edited by
            #5

            The sample SGaist posted should work. In your screen capture the right side is a little wider then the left so I think it is there but there it has no reason to be wider than what it is.

            A small variation to test this assumption:

            @
            m_ObjectListWidget = new QListWidget;
            m_PhysicsConfWidget = new QTableView;
            m_RenderWidget = new QWidget;
            m_MainWidget = new QWidget;

             m_RenderWidget->setMinimumWidth(100);
            
                m_VBoxLayout = new QVBoxLayout;
                m_VBoxLayout->addWidget(m_PhysicsConfWidget);
                m_VBoxLayout->addWidget(m_ObjectListWidget);
             
                m_HBoxLayout = new QHBoxLayout(m_MainWidget);
                m_HBoxLayout->addLayout(m_VBoxLayout);
                m_HBoxLayout->addWidget(m_RenderWidget);
             
                setCentralWidget(m_MainWidget);
            

            @

            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