Return an object in a role in Python and get a reference of another object in QML

后端 未结 3 1629
粉色の甜心
粉色の甜心 2021-01-07 10:29

I\'m writing a Twitter client. I implemented TweetItem and TweetModel. The issue is that there is a role in TweetItem called ori

3条回答
  •  爱一瞬间的悲伤
    2021-01-07 11:05

    1. Straight answer: you got undefined because, because your TweetItem.original is in fact None.
    2. I'm not sure what you are trying to accomplish, but I want to clear some possible misunderstandings. QAbstractItemModel is a model class too, it's somewhat strange to see

      def data(self, index, role):
          return self.tweets[index.row()].data(role)
      

    there.

提交回复
热议问题