Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Rearranging Items contained in GridLayout?
Forum Updated to NodeBB v4.3 + New Features

Rearranging Items contained in GridLayout?

Scheduled Pinned Locked Moved QML and Qt Quick
4 Posts 2 Posters 1.1k 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.
  • P Offline
    P Offline
    pmendl
    wrote on last edited by
    #1

    Is there some recommended way how to achieve the following?
    I do use GridLayout populated with Items (in fact interpreting language icons dynamically created from C++), which are arranged based on :

    1. columns count (to automatically wrap long rows)
    2. multiple rows (to allow programmer to split "code" into logical sections.

    Now I need to insert new command not at the end of last row, but right before (or after if it would get easier) other (user selected) icon. I have pointer to the icon Item ready, however I did not find any API functionality to rearrange Items in GridLayout. (After some googling I understood (maybee wrong), that stackBefore() just rearranges Z-order, but not the order Items are displayed inside GridLayout.)

    In several posts recommended strategy "remove all Items and add them all into GridLayout again in the newly requested order" seems a bit stone age to me and I will use it as fall back strategy, but not before I will get confirmation here that there is no more sophisticated alternative in QML API.

    1 Reply Last reply
    0
    • p3c0P Offline
      p3c0P Offline
      p3c0
      Moderators
      wrote on last edited by
      #2

      Hi,

      GridLayout doesnot have any insert methods. Instead if you use GridView, you can provide a C++/QML model where you can insert Items at any particular location.

      157

      1 Reply Last reply
      0
      • P Offline
        P Offline
        pmendl
        wrote on last edited by
        #3

        Thanks for advice. I did not dig into QML model/view API yet, but will do as this my project is partly intended as hands on training for Qt. Will come back with my experience/solution once I get so far.

        1 Reply Last reply
        0
        • p3c0P Offline
          p3c0P Offline
          p3c0
          Moderators
          wrote on last edited by
          #4

          Ok. Take your time and Happy Coding! :)

          157

          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