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. Drag and Drop from 2 Listwidgets, but change text after dropping in 2nd Listwidget

Drag and Drop from 2 Listwidgets, but change text after dropping in 2nd Listwidget

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++qt 5.4qlistwidgetqlistwidgetitemdrag and drop
5 Posts 2 Posters 651 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.
  • L Offline
    L Offline
    learnist
    wrote on 17 Jun 2020, 19:20 last edited by
    #1

    smp.JPG

    The 'Country' QListwidget is going to be populated with country names items and if the user drags that an item and drops it in capital QListWidget, it should show me the name of its capital , i.e that item text should change in capital QListWidget.

    for example - an item named "Russia" in country listwidget , after dragging and dropping , the item should be renamed to "Moscow".

    so far to enable drag and drop, i have just written this code,

    ui->country_listwidget->setDragEnabled(true);
    ui->capital_listwidget->setAcceptDrops(true);
    

    is this possible in QT?

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 17 Jun 2020, 19:40 last edited by
      #2

      Hi,

      There might be several ways. One of which is to subclass and re-implement the dropMimeData method to replace the country by its capital.

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

      L 1 Reply Last reply 17 Jun 2020, 20:19
      0
      • S SGaist
        17 Jun 2020, 19:40

        Hi,

        There might be several ways. One of which is to subclass and re-implement the dropMimeData method to replace the country by its capital.

        L Offline
        L Offline
        learnist
        wrote on 17 Jun 2020, 20:19 last edited by
        #3

        @SGaist , Oh okay, thanks, this narrows down my search, but what code logic can i put in drop mime data method,
        can you provide code segment.

        L 1 Reply Last reply 17 Jun 2020, 21:38
        0
        • L learnist
          17 Jun 2020, 20:19

          @SGaist , Oh okay, thanks, this narrows down my search, but what code logic can i put in drop mime data method,
          can you provide code segment.

          L Offline
          L Offline
          learnist
          wrote on 17 Jun 2020, 21:38 last edited by
          #4

          @learnist Solved using item delegate , Thanks for the input

          1 Reply Last reply
          0
          • S Offline
            S Offline
            SGaist
            Lifetime Qt Champion
            wrote on 18 Jun 2020, 19:45 last edited by
            #5

            Good then please mark the thread as solved using the "Topic Tools" button so that other forum users may know a solution has been found.

            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

            2/5

            17 Jun 2020, 19:40

            • Login

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