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. Signal on TreeView column move

Signal on TreeView column move

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
11 Posts 3 Posters 3.4k Views 2 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.
  • CesarioC Offline
    CesarioC Offline
    Cesario
    wrote on last edited by
    #1

    Hi.
    I have a qml treeview with several column. The user can move the colum ... I do not see any signal that could be intercepted to handle the event.
    Everything work fine, but I need to know that the user change the column order.
    Thanks for any suggestion.

    1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      Here you go: QHeaderView::sectionMoved().

      Further info here: http://doc.qt.io/qt-5/qheaderview.html#moving-header-sections

      (Z(:^

      CesarioC 1 Reply Last reply
      0
      • sierdzioS sierdzio

        Here you go: QHeaderView::sectionMoved().

        Further info here: http://doc.qt.io/qt-5/qheaderview.html#moving-header-sections

        CesarioC Offline
        CesarioC Offline
        Cesario
        wrote on last edited by
        #3

        @sierdzio
        Thanks for your answer, but unfortunately it cannot solve my problem.
        I do not have any QtableWidget, QtableView or QtreeView. I need to handle the signal in the qml module.

        TreeView {
        …
        model : myModel
        TableViewColumn {
        role : "role1"
        title : "title1"
        movable : true
        resizable : true
        delegate : Item { …}
        }
        …
        TableViewColumn {
        role : "role-n"
        title : "title-n"
        movable : true
        resizable : true
        delegate : Item { …}
        }
        }

        The application user can move the column as he would like, and I have to save his settings for the next session. But I do not see any way to be notified in the qml module.

        Should I redesign my application in order to use a QtreeView ?

        Thanks again for any suggestions.

        VRoninV 1 Reply Last reply
        0
        • sierdzioS Offline
          sierdzioS Offline
          sierdzio
          Moderators
          wrote on last edited by
          #4

          Ah, QML, sorry. I assumed we talk about widgets.

          In QML I'm not sure... it may well be that this functionality is missing altogether. One possible hint I've found is this: http://doc.qt.io/qt-5/qml-qtquick-controls-treeview.html#headerDelegate-prop Maybe you could use Connections element to react to changes to styleData.column property. I'm not sure if it will work, though.

          (Z(:^

          CesarioC 1 Reply Last reply
          0
          • sierdzioS sierdzio

            Ah, QML, sorry. I assumed we talk about widgets.

            In QML I'm not sure... it may well be that this functionality is missing altogether. One possible hint I've found is this: http://doc.qt.io/qt-5/qml-qtquick-controls-treeview.html#headerDelegate-prop Maybe you could use Connections element to react to changes to styleData.column property. I'm not sure if it will work, though.

            CesarioC Offline
            CesarioC Offline
            Cesario
            wrote on last edited by
            #5

            @sierdzio said in Signal on TreeView column move:

            column
            I didn't fully understad your answer: I know that styleData.column is changed:
            Quite easy in development phase ...
            headerDelegate: Item {
            ...
            Text { text : styleData.value + " : " + styleData.column}

                }
            

            )

            CesarioC 1 Reply Last reply
            0
            • CesarioC Cesario

              @sierdzio said in Signal on TreeView column move:

              column
              I didn't fully understad your answer: I know that styleData.column is changed:
              Quite easy in development phase ...
              headerDelegate: Item {
              ...
              Text { text : styleData.value + " : " + styleData.column}

                  }
              

              )

              CesarioC Offline
              CesarioC Offline
              Cesario
              wrote on last edited by
              #6

              @Cesario

              ...SORRY: I submit an uncomplete post.

              I didn't fully understand your answer: I know that styleData.column is changed:
              Quite easy in development phase ...
              headerDelegate: Item {
              ...
              Text { text : styleData.value + " : " + styleData.column}
               ....
              }
              

              But I'm not able to handle any event. I do not understand your quote about using a Connection ...

              1 Reply Last reply
              0
              • sierdzioS Offline
                sierdzioS Offline
                sierdzio
                Moderators
                wrote on last edited by
                #7

                I was thinking about something like this:

                Connection {
                    target: headerDelegate1.styleData.column
                    onColumnChanged: something();
                }
                

                But now that I wrote it down I see it won't work, because styleData is an attached property, it won't be available outside of headerDetegate body. So unless you declare signal handling there, inside your headerDelegate: Item { (where I'm still very unsure if it will work), my suggestion is not a correct one.

                (Z(:^

                1 Reply Last reply
                1
                • CesarioC Offline
                  CesarioC Offline
                  Cesario
                  wrote on last edited by
                  #8

                  I didn't find any solution.
                  So I'm going to disable the user column move and add an extra option panel to allow the user to set up the columns order … quite obsolete, but I can not help it.
                  Thanks anyway for your comments.

                  1 Reply Last reply
                  0
                  • CesarioC Cesario

                    @sierdzio
                    Thanks for your answer, but unfortunately it cannot solve my problem.
                    I do not have any QtableWidget, QtableView or QtreeView. I need to handle the signal in the qml module.

                    TreeView {
                    …
                    model : myModel
                    TableViewColumn {
                    role : "role1"
                    title : "title1"
                    movable : true
                    resizable : true
                    delegate : Item { …}
                    }
                    …
                    TableViewColumn {
                    role : "role-n"
                    title : "title-n"
                    movable : true
                    resizable : true
                    delegate : Item { …}
                    }
                    }

                    The application user can move the column as he would like, and I have to save his settings for the next session. But I do not see any way to be notified in the qml module.

                    Should I redesign my application in order to use a QtreeView ?

                    Thanks again for any suggestions.

                    VRoninV Offline
                    VRoninV Offline
                    VRonin
                    wrote on last edited by
                    #9

                    @Cesario said in Signal on TreeView column move:

                    I need to handle the signal in the qml module.

                    You can't, when you move the column the model will have no idea it happened, the view just remaps the indexes internally.

                    "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                    ~Napoleon Bonaparte

                    On a crusade to banish setIndexWidget() from the holy land of Qt

                    1 Reply Last reply
                    0
                    • CesarioC Offline
                      CesarioC Offline
                      Cesario
                      wrote on last edited by
                      #10

                      So what ?

                      1. The indexes are internally rearranged, so I cannot know anymore the column #3 is that one with role =’role03’;
                      2. I cannot intercept the click on the header (if you define a MouseArea on the headerDelegate you will file to handle any signals!;
                      3. There are no clear signals to handle drop event (you know, the column move is managed internally like a drag/drop area);

                      No way. Forget about... It should be something wrong in my post: I cannot understand why it is so easy to move around a TableViewColumn and there is no way to handle the event.

                      1 Reply Last reply
                      0
                      • sierdzioS Offline
                        sierdzioS Offline
                        sierdzio
                        Moderators
                        wrote on last edited by
                        #11

                        Looks like a missing feature. Maybe suggest it on https://bugreports.qt.io?

                        (Z(:^

                        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