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. QHBoxLayout not working properly
Forum Updated to NodeBB v4.3 + New Features

QHBoxLayout not working properly

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 316 Views 3 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.
  • B Offline
    B Offline
    Batyu
    wrote on last edited by
    #1

    I have a very simple code:

    m_HBoxLayout = new QHBoxLayout(parent);
    m_VBoxLayout = new QVBoxLayout(parent);
    m_ProfilePicture = new QLabel("PFP", parent);
    m_SlabName = new QLabel("Name", parent);
    m_StatusMessage = new QLabel("Status", parent);
    m_HBoxLayout->addWidget(m_ProfilePicture);
    m_VBoxLayout->addWidget(m_SlabName);
    m_VBoxLayout->addWidget(m_StatusMessage);
    m_HBoxLayout->addLayout(m_VBoxLayout);
    

    This is how it looks like after i run it:
    result
    Can somebody tell me what have I missed?
    I want it to look like something like this:
    desired result

    JKSHJ SGaistS 2 Replies Last reply
    0
    • B Batyu

      I have a very simple code:

      m_HBoxLayout = new QHBoxLayout(parent);
      m_VBoxLayout = new QVBoxLayout(parent);
      m_ProfilePicture = new QLabel("PFP", parent);
      m_SlabName = new QLabel("Name", parent);
      m_StatusMessage = new QLabel("Status", parent);
      m_HBoxLayout->addWidget(m_ProfilePicture);
      m_VBoxLayout->addWidget(m_SlabName);
      m_VBoxLayout->addWidget(m_StatusMessage);
      m_HBoxLayout->addLayout(m_VBoxLayout);
      

      This is how it looks like after i run it:
      result
      Can somebody tell me what have I missed?
      I want it to look like something like this:
      desired result

      JKSHJ Offline
      JKSHJ Offline
      JKSH
      Moderators
      wrote on last edited by
      #2

      @Batyu said in QHBoxLayout not working properly:

      Can somebody tell me what have I missed?

      topLevelWidget->setLayout(m_HBoxLayout)

      Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

      B 1 Reply Last reply
      1
      • JKSHJ JKSH

        @Batyu said in QHBoxLayout not working properly:

        Can somebody tell me what have I missed?

        topLevelWidget->setLayout(m_HBoxLayout)

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

        @JKSH Thanks

        1 Reply Last reply
        0
        • B Batyu

          I have a very simple code:

          m_HBoxLayout = new QHBoxLayout(parent);
          m_VBoxLayout = new QVBoxLayout(parent);
          m_ProfilePicture = new QLabel("PFP", parent);
          m_SlabName = new QLabel("Name", parent);
          m_StatusMessage = new QLabel("Status", parent);
          m_HBoxLayout->addWidget(m_ProfilePicture);
          m_VBoxLayout->addWidget(m_SlabName);
          m_VBoxLayout->addWidget(m_StatusMessage);
          m_HBoxLayout->addLayout(m_VBoxLayout);
          

          This is how it looks like after i run it:
          result
          Can somebody tell me what have I missed?
          I want it to look like something like this:
          desired result

          SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          @Batyu said in QHBoxLayout not working properly:

          m_HBoxLayout = new QHBoxLayout(parent);
          m_VBoxLayout = new QVBoxLayout(parent);

          Passing a parent to a layout automatically applies the layout to the parent.

          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 Extensions
          • Unsolved