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

movable columns for customheaderview

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 3 Posters 463 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.
  • NevezN Offline
    NevezN Offline
    Nevez
    wrote on last edited by Nevez
    #1

    1bec30ee-c86e-4ccb-96c8-6001f6848ae6-image.png

    hi,
    I have a customheader class that I created by subclassing QHeaderview as above.
    I made this view inspired by the link below, I'm sure you know this link.
    link

    How can I change the order of the columns by dragging the labels in the table that looks like the picture above?

    I know that I need to use events such as drop event, drag for these. But which class should I apply these events to exactly?
    For example, if I apply it in the HeaderView class, the drop event function on the labels does not seem to work.

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Do you mean that QHeaderView::setSectionsMovable does not work for you ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      1
      • NevezN Offline
        NevezN Offline
        Nevez
        wrote on last edited by Nevez
        #3

        @SGaist said in movable columns for customheaderview:

        Do you mean that QHeaderView::setSectionsMovable does not work for you ?

        yes this is not working. Because QLabels are placed in the headers.
        So how can I do this through these labels?

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          I would try setting the transparent for mouse property on the label.

          That said, wouldn't it have been lighter to implement a custom header view rather than use labels ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          1
          • NevezN Offline
            NevezN Offline
            Nevez
            wrote on last edited by
            #5

            @SGaist said in movable columns for customheaderview:

            I would try setting the transparent for mouse property on the label.

            This seems to work partially. but still not very convenient. because the labels don't move while dragging and the title names seem to be dragged in the background. and the first column title never moves.

            @SGaist said in movable columns for customheaderview:

            That said, wouldn't it have been lighter to implement a custom header view rather than use labels ?

            I already did this by creating a custom customheaderview.
            I can share the code if you want.
            In the form of setheader(myheaderview)...

            How can I get a signal from labels in an array with connect?
            example: QMap<int , QLabel> labelsmap. // it has 10 labels

            JonBJ 1 Reply Last reply
            0
            • NevezN Nevez

              @SGaist said in movable columns for customheaderview:

              I would try setting the transparent for mouse property on the label.

              This seems to work partially. but still not very convenient. because the labels don't move while dragging and the title names seem to be dragged in the background. and the first column title never moves.

              @SGaist said in movable columns for customheaderview:

              That said, wouldn't it have been lighter to implement a custom header view rather than use labels ?

              I already did this by creating a custom customheaderview.
              I can share the code if you want.
              In the form of setheader(myheaderview)...

              How can I get a signal from labels in an array with connect?
              example: QMap<int , QLabel> labelsmap. // it has 10 labels

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

              @Nevez said in movable columns for customheaderview:

              How can I get a signal from labels in an array with connect?

              Just connect them? Not sure what your issue us.

              example: QMap<int , QLabel> labelsmap. // it has 10 labels

              You will want QLabel *, not QLabel. QWidgets only live where you actually place them in the UI. You can't (and would not want to) copy them, so you can only deal in pointers to the actual widget.

              1 Reply Last reply
              2

              • Login

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