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. C++ and Layout

C++ and Layout

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 789 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.
  • N Offline
    N Offline
    Neko
    wrote on last edited by
    #1

    Hey guys,
    probably a pretty easy to answer question, but i cant find an answer to it.

    How can i create a Layout that has a small List of Items on the left side and right next to it alot of icons depending on which item on the left side i have selected.

    I tried using a QGridLayout and adding 2 QListView Widgets to it.
    WidgetA one showed me my categories, but took more than half the screen.
    WidgetB wasnt filled by me yet, but it was super small on the right side of the screen because WidgetA one was dominating.

    When i switched both of them in my QGridLayout, WidgetB was now the dominating and WidgetA the super small one.

    Example code:

    QGridLayout * layout = new QGridLayout();
    layout->addWidget(_categoryWidget, 0, 0, 1, 1);
    layout->addWidget(_iconWidget, 0, 1, 1, 2);
    setLayout(layout)

    Category / IconWidget is:

    _listWidget = new QListWidget;
    QVBoxLayout * layout = new QVBoxLayout;
    layout->addWidget(_listWidget);
    setLayout(layout);

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

      Hi
      You can use layoutStretch to tell how you want space divided
      alt text

      1 Reply Last reply
      0
      • N Offline
        N Offline
        Neko
        wrote on last edited by
        #3

        I'm not using any designer.
        It's all written in C++.

        Here is my current result:

        0_1531233691544_051134ca-aa41-4f71-8f8a-9f04a56417db-image.png

        I've added buttons to my layout for each column.
        _layout->addWidget(new QPushButton("A"), 0, 0, 1, 1);
        _layout->addWidget(new QPushButton("B"), 0, 1, 1, 1);
        _layout->addWidget(new QPushButton("C"), 0, 2, 1, 1);

        Then i have:

        _layout->addWidget(_categoryWidget->getUI(), 1, 0, 1, 1);
        _layout->addWidget(_assetWidget->getUI(), 1, 1, 1, 2);

        And my Widgets actually are just new QListView Widgets and set as a Widget in a seperate QGridLayout which is added as "CategoryWidget->getUI()"

        How can i decrease the size of column a to be the same size as my ListView in column A ? Is there any automatic way to do it ?

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          hi
          Designer or code matters not. Designer creates c++ code.
          you can still use LayoutStretch.
          Or set Min/Max sizes on the widgets.
          alt text

          1 Reply Last reply
          1
          • N Offline
            N Offline
            Neko
            wrote on last edited by
            #5

            Thanks for your help.
            I've figured it out :)

            Had to change the size policy of my ListViews and also set the maximum width.

            Thanks for your help tho :)

            mrjjM 1 Reply Last reply
            1
            • N Neko

              Thanks for your help.
              I've figured it out :)

              Had to change the size policy of my ListViews and also set the maximum width.

              Thanks for your help tho :)

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @Neko
              Super
              please mark as solved.

              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