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. QAbstractItemModel get view
Forum Updated to NodeBB v4.3 + New Features

QAbstractItemModel get view

Scheduled Pinned Locked Moved Solved QML and Qt Quick
4 Posts 2 Posters 625 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.
  • D Offline
    D Offline
    damianatorrpm
    wrote on 2 Sept 2020, 14:40 last edited by
    #1

    Is it possible in the data() function of an abstract item model to get the QObject* of the requesting view?

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

      Hi,

      You can't and you should not do that.

      Why would you need that information in your model ?

      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
      • D Offline
        D Offline
        damianatorrpm
        wrote on 2 Sept 2020, 19:35 last edited by damianatorrpm 9 Feb 2020, 19:36
        #3

        @SGaist
        Hi,

        The model should return different values for the different requesters (different windows, same model).
        Currently I'm using a QList (I'm sure the performance if it were possible would be much better in my usecase) with all the information, but it's pretty complex as qml sortfilterproxymodel is also being used. If you are certain that this is not possible, than the question is answered, thanks!

        1 Reply Last reply
        0
        • S Offline
          S Offline
          SGaist
          Lifetime Qt Champion
          wrote on 2 Sept 2020, 20:46 last edited by
          #4

          Then you should use the appropriate roles from your views to request the data. It's not the role of the model to accommodate the views that are on top of it.

          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

          2/4

          2 Sept 2020, 17:46

          • Login

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