Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Solved QAbstractItemModel get view

    QML and Qt Quick
    2
    4
    129
    Loading More Posts
    • 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
      damianatorrpm last edited by

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

      1 Reply Last reply Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 1
        • D
          damianatorrpm last edited by damianatorrpm

          @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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 1
            • First post
              Last post