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. Distinguish between setData() called from code or after user edit
Forum Updated to NodeBB v4.3 + New Features

Distinguish between setData() called from code or after user edit

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 659 Views 3 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.
  • M Offline
    M Offline
    Mark81
    wrote on last edited by
    #1

    I'm pretty sure it's written in the documentation but I cannot find anything perhaps because I'm using the wrong search words.
    I'm looking for a way to distinguish if a call to setData() for a QAbstractTableModel comes from a line of my code or when the user edited the table.

    Gojir4G 1 Reply Last reply
    0
    • M Mark81

      I'm pretty sure it's written in the documentation but I cannot find anything perhaps because I'm using the wrong search words.
      I'm looking for a way to distinguish if a call to setData() for a QAbstractTableModel comes from a line of my code or when the user edited the table.

      Gojir4G Offline
      Gojir4G Offline
      Gojir4
      wrote on last edited by
      #2

      Hi @Mark81,

      I don't know about this feature. But I guess you can use another role than Qt::EditRole when calling setData().

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

        Hi,

        Why do you need to know the difference ?

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

        M 1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Why do you need to know the difference ?

          M Offline
          M Offline
          Mark81
          wrote on last edited by
          #4

          @SGaist Because I need to automate some stuff only if was the user that changed the data. Otherwise it will be triggered even when I load the data into the model. Anyway the solution proposed by @Gojir4 did the trick.

          Pablo J. RoginaP 1 Reply Last reply
          0
          • M Mark81

            @SGaist Because I need to automate some stuff only if was the user that changed the data. Otherwise it will be triggered even when I load the data into the model. Anyway the solution proposed by @Gojir4 did the trick.

            Pablo J. RoginaP Offline
            Pablo J. RoginaP Offline
            Pablo J. Rogina
            wrote on last edited by
            #5

            @Mark81 said in Distinguish between setData() called from code or after user edit:

            the solution proposed by @Gojir4 did the trick.

            please don't forget to mark your post as solved! Thanks

            Upvote the answer(s) that helped you solve the issue
            Use "Topic Tools" button to mark your post as Solved
            Add screenshots via postimage.org
            Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

            1 Reply Last reply
            1

            • Login

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