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. UI Forms Custom Properties
QtWS25 Last Chance

UI Forms Custom Properties

Scheduled Pinned Locked Moved Unsolved General and Desktop
forms
8 Posts 2 Posters 2.2k 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.
  • S Offline
    S Offline
    Suths
    wrote on last edited by
    #1

    Hi Everyone,

    I have a few forms for custom widgets etc, which for example have tree views on them. I have other widgets that can accept drag and drop events. I'm trying to uniquely identify these views such that the QGraphicsSceneDragDropEvent source for example can tell me where that event has originated from.
    There are a couple of methods I have thought about (trying to avoid having to subclass a treeview):

    • Use the object name - As the name space is lost this is not unique for the application.
    • Use QMetaInfo - for forms I’m not sure how to do this for auto generated forms.

    Anyone have any ideas?

    Thanks in advance.

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

      Hi,

      Out of curiosity, why do you need to know the widget from which the drag & drop operation started ?

      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
      0
      • S Offline
        S Offline
        Suths
        wrote on last edited by
        #3

        For validation only certain items within the tree view are permissible to be dropped, and the behavior of the dragged from location has an impact on the drop behavior. As this is a plugin based application i'm trying to design something a bit more scalable .

        For example there is a tree view with elements that can be created, and a tree view of elements that already exist but can be shown. An element from the "create" tree view will create the object and then show it. Where as the one from the "show" tree view will only be shown. If that makes any sense.

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

          In that case shouldn't that information rather be encoded in the data you are passing around ? Doing so, you become independent on the widget from which the operation starts.

          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
          0
          • S Offline
            S Offline
            Suths
            wrote on last edited by
            #5

            Perhaps. The problem was I was trying to make the item dropped agnostic to it's source. For example a QListWidget, a QTreeView etc. I felt at the time forcing the data type across all possible drag sources to comply with some interface was nothing something I wanted to do. I rather constrain the logic higher up to say "I am only interested in event from that / those source(s)". Leaving lower level logic to determine the type of object being passed and the action to take.

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

              You can then write a filter that you install and configure per widget.

              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
              0
              • S Offline
                S Offline
                Suths
                wrote on last edited by Suths
                #7

                @SGaist Apologies i'm late replying.

                Thanks for the useful thoughts. Do you mind if a through a couple more questions at you, whilst I try to knock up an example using your method.

                • Lets say i'm using a tree view and a list view to provide the drag from sources. I believe using your object I would have to cast the event source to one of these two types (tree or list) then obtain the selected item (i.e the item in the selection model) that was actually dragged onto the widget. Whilst this might be OK from a list view or tree view (only 2 branches), for more sources the amount of casts would potentially grow he same rate.

                • Again using the example of a list view providing a data item that is exposed through the native interface without having to do additional casting i think would be additional work. for example you might just want to use a standard item model.

                Hope that makes some sort of sense.

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

                  One way to do the filtering more cleanly would be to use custom mime-types then in your drop target, you check that mime type and if not whitelisted then refuse the drop. No need for any knowledge of the widget where the item comes from.

                  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
                  0

                  • Login

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