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

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

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 2 Posters 359 Views 1 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
    beautifulcloud
    wrote on 29 Jul 2023, 14:38 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 29 Jul 2023, 15:07
    0
    • B beautifulcloud
      29 Jul 2023, 14:38

      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 29 Jul 2023, 15:07 last edited by
      #2

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

      B 1 Reply Last reply 29 Jul 2023, 17:03
      4
      • M mpergand
        29 Jul 2023, 15:07

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

        B Offline
        B Offline
        beautifulcloud
        wrote on 29 Jul 2023, 17:03 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 29 Jul 2023, 22:16
        0
        • B beautifulcloud
          29 Jul 2023, 17:03

          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 29 Jul 2023, 22:16 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.

          B 2 Replies Last reply 29 Jul 2023, 22:49
          1
          • M mpergand
            29 Jul 2023, 22:16

            @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.

            B Offline
            B Offline
            beautifulcloud
            wrote on 29 Jul 2023, 22:49 last edited by
            #5

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

            1 Reply Last reply
            0
            • M mpergand
              29 Jul 2023, 22:16

              @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.

              B Offline
              B Offline
              beautifulcloud
              wrote on 1 Aug 2023, 16:30 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
              • B beautifulcloud has marked this topic as solved on 1 Aug 2023, 16:31
              • B beautifulcloud referenced this topic on 1 Aug 2023, 16:45

              3/6

              29 Jul 2023, 17:03

              • Login

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