Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Solved C++ and Layout

    General and Desktop
    2
    6
    437
    Loading More Posts
    • 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
      Neko last edited by

      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 Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

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

        1 Reply Last reply Reply Quote 0
        • N
          Neko last edited by

          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 Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion last edited by

            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 Reply Quote 1
            • N
              Neko last edited by

              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 :)

              mrjj 1 Reply Last reply Reply Quote 1
              • mrjj
                mrjj Lifetime Qt Champion @Neko last edited by

                @Neko
                Super
                please mark as solved.

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post