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. Insert widgets from the left in an horizontal layout
Forum Updated to NodeBB v4.3 + New Features

Insert widgets from the left in an horizontal layout

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

    Hello!

    I am doing a task in which I have to insert widgets in an horizontal layout. How can I do to insert them by the left?

    Thank you very much!

    JonBJ 1 Reply Last reply
    0
    • ivanicyI ivanicy

      Hello!

      I am doing a task in which I have to insert widgets in an horizontal layout. How can I do to insert them by the left?

      Thank you very much!

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @ivanicy
      https://doc.qt.io/qt-5/qboxlayout.html#insertWidget. QBoxLayout::insertWidget(int index, QWidget *widget) inserts (at the left) if you pass e.g. 0 for index.

      ivanicyI 1 Reply Last reply
      1
      • JonBJ JonB

        @ivanicy
        https://doc.qt.io/qt-5/qboxlayout.html#insertWidget. QBoxLayout::insertWidget(int index, QWidget *widget) inserts (at the left) if you pass e.g. 0 for index.

        ivanicyI Offline
        ivanicyI Offline
        ivanicy
        wrote on last edited by
        #3

        @JonB Yes but, when I want to insert another widget... if I do that, it will overlay it

        JonBJ 1 Reply Last reply
        0
        • ivanicyI ivanicy

          @JonB Yes but, when I want to insert another widget... if I do that, it will overlay it

          JonBJ Online
          JonBJ Online
          JonB
          wrote on last edited by JonB
          #4

          @ivanicy
          No it won't, that's why the method is insert widget, and docs say it inserts! :) There is no "replacing/overlaying". Why don't you try it?

          As a different approach, there is also https://doc.qt.io/qt-5/qboxlayout.html#Direction-enum, QBoxLayout::RightToLeft, which would let you use addWidget() and put it at the left instead of the normal right. But it's really the same sort of thing.

          ivanicyI 1 Reply Last reply
          2
          • JonBJ JonB

            @ivanicy
            No it won't, that's why the method is insert widget, and docs say it inserts! :) There is no "replacing/overlaying". Why don't you try it?

            As a different approach, there is also https://doc.qt.io/qt-5/qboxlayout.html#Direction-enum, QBoxLayout::RightToLeft, which would let you use addWidget() and put it at the left instead of the normal right. But it's really the same sort of thing.

            ivanicyI Offline
            ivanicyI Offline
            ivanicy
            wrote on last edited by
            #5

            @JonB Oh, sorry man. I tried it yesterday with addWidget method. But with insertWidget works fine!! Thank you very much!

            JonBJ 1 Reply Last reply
            0
            • ivanicyI ivanicy

              @JonB Oh, sorry man. I tried it yesterday with addWidget method. But with insertWidget works fine!! Thank you very much!

              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by
              #6

              @ivanicy
              :) Even addWidget() won't "replace/overlay", addWidget() is only insertWidget(-1), they both "insert" at the end.

              1 Reply Last reply
              1

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved