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. Position images in a widget and return to the line on overflow
QtWS25 Last Chance

Position images in a widget and return to the line on overflow

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

    Hello community,

    So far I've used a few simple elements of QT and I'm stuck on what I'd like to achieve

    To simplify my idea, it would be to put images (16x16 blue squares) vertically aligned in a widget and when it reaches the end of the widget size, the images would be placed in a line below, and so on
    ff8a044e-60d2-493f-9247-61260ec741d5-image.png

    I'm sure it's not complicated, but I don't know QT very well. I've already tried the simple grid alignment in the widget and a few other elements, but it didn't work.

    Thanks

    M 1 Reply Last reply
    0
    • beautifulcloudB beautifulcloud

      Hello community,

      So far I've used a few simple elements of QT and I'm stuck on what I'd like to achieve

      To simplify my idea, it would be to put images (16x16 blue squares) vertically aligned in a widget and when it reaches the end of the widget size, the images would be placed in a line below, and so on
      ff8a044e-60d2-493f-9247-61260ec741d5-image.png

      I'm sure it's not complicated, but I don't know QT very well. I've already tried the simple grid alignment in the widget and a few other elements, but it didn't work.

      Thanks

      M Offline
      M Offline
      mpergand
      wrote on last edited by
      #2

      Hi @beautifulcloud
      Have a look at:
      https://doc.qt.io/qt-6/qtwidgets-layouts-flowlayout-example.html

      beautifulcloudB 1 Reply Last reply
      4
      • M mpergand

        Hi @beautifulcloud
        Have a look at:
        https://doc.qt.io/qt-6/qtwidgets-layouts-flowlayout-example.html

        beautifulcloudB Offline
        beautifulcloudB Offline
        beautifulcloud
        wrote on last edited by
        #3

        Hello @mpergand ,

        I believe it's what I need

        Tell me if I'm wrong :

        • I created a class flowlayout thanks to a recovered code, so a flowlayout.h and a flowlayout.cpp
        • In qt design I clicked on "Promote to" and I added the layout flowlayout.h which I then activated

        But when compiling the flowlayout header is not found by the ui file

        F:\build-Sunfade-Desktop_Qt_6_5_1_MinGW_64_bit-Debug\Sunfade_autogen\include\ui_secondarywindow.h:22: erreur : flowlayout.h: No such file or directory
        

        I added the files in CMakelist and added an include in the source .cpp file

        Thanks for your answer

        M 1 Reply Last reply
        0
        • beautifulcloudB beautifulcloud

          Hello @mpergand ,

          I believe it's what I need

          Tell me if I'm wrong :

          • I created a class flowlayout thanks to a recovered code, so a flowlayout.h and a flowlayout.cpp
          • In qt design I clicked on "Promote to" and I added the layout flowlayout.h which I then activated

          But when compiling the flowlayout header is not found by the ui file

          F:\build-Sunfade-Desktop_Qt_6_5_1_MinGW_64_bit-Debug\Sunfade_autogen\include\ui_secondarywindow.h:22: erreur : flowlayout.h: No such file or directory
          

          I added the files in CMakelist and added an include in the source .cpp file

          Thanks for your answer

          M Offline
          M Offline
          mpergand
          wrote on last edited by mpergand
          #4

          @beautifulcloud
          I don't know, I don't use Qt 6 or cmake.
          There are numerous examples in the Qt folder at:
          Qt XX/examples/
          You can create a project from these examples in QtCreator:

          • clik on Welcome tab on the left
          • type flowlayout in the search field
          • click on FlowLayout example thumbnail

          a project is automatically created and see if it works.

          beautifulcloudB 2 Replies Last reply
          1
          • M mpergand

            @beautifulcloud
            I don't know, I don't use Qt 6 or cmake.
            There are numerous examples in the Qt folder at:
            Qt XX/examples/
            You can create a project from these examples in QtCreator:

            • clik on Welcome tab on the left
            • type flowlayout in the search field
            • click on FlowLayout example thumbnail

            a project is automatically created and see if it works.

            beautifulcloudB Offline
            beautifulcloudB Offline
            beautifulcloud
            wrote on last edited by
            #5

            @mpergand
            Oh nice I will look for it tomorrow,
            thanks for your time

            1 Reply Last reply
            0
            • M mpergand

              @beautifulcloud
              I don't know, I don't use Qt 6 or cmake.
              There are numerous examples in the Qt folder at:
              Qt XX/examples/
              You can create a project from these examples in QtCreator:

              • clik on Welcome tab on the left
              • type flowlayout in the search field
              • click on FlowLayout example thumbnail

              a project is automatically created and see if it works.

              beautifulcloudB Offline
              beautifulcloudB Offline
              beautifulcloud
              wrote on last edited by
              #6

              Hello @mpergand ,

              As with the old code I integrated the flowlayout object in my project and I didn't manage to implement it in QT Design, but it does not matter because I left to do it in the source code.

              But the flowlayout was what I was looking for so thanks!

              1 Reply Last reply
              1
              • beautifulcloudB beautifulcloud has marked this topic as solved on
              • beautifulcloudB beautifulcloud referenced this topic on

              • Login

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