Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/fortran/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python PyQt5角色与MVC_Python_Model View Controller_Pyqt_Pyqt5 - Fatal编程技术网

Python PyQt5角色与MVC

Python PyQt5角色与MVC,python,model-view-controller,pyqt,pyqt5,Python,Model View Controller,Pyqt,Pyqt5,我试着编写一个小的ToDo应用程序,但无意中发现对模型如何处理角色缺乏理解,我的意思是,它如何区分一个角色和另一个角色?是不是,就像,同时检查所有这些 我很乐意消除我的好奇心 class TodoModel(QtCore.QAbstractListModel): """ Model for handling data""" def __init__(self, todos=None, *args, **kwargs)

我试着编写一个小的ToDo应用程序,但无意中发现对模型如何处理角色缺乏理解,我的意思是,它如何区分一个角色和另一个角色?是不是,就像,同时检查所有这些

我很乐意消除我的好奇心

class TodoModel(QtCore.QAbstractListModel):

    """ Model for handling data"""

    def __init__(self, todos=None, *args, **kwargs):
        super(TodoModel, self).__init__(*args, **kwargs)
        self.todos = todos or []

    def data(self, index, role):
        if role == Qt.DisplayRole: #That Line
            status, text = self.todos[index.row()]
            return text
        
        if role == Qt.DecorationRole: #And This One
            status, text = self.todos[index.row()]
            if status:
                return tick

    def rowCount(self, index):
        return len(self.todos)

角色用于存储和访问特定项目的一种信息。Qt的开发人员意识到存在基本信息,因此通过以下方式建立了基本角色:

(有更多角色,请使用链接查看)

与预先建立的角色一样,默认代理使用它来获取绘制项目的信息


有关更多信息,请查看角色,这些角色用于存储和访问特定项目的一种信息。Qt的开发人员意识到存在基本信息,因此通过以下方式建立了基本角色:

(有更多角色,请使用链接查看)

与预先建立的角色一样,默认代理使用它来获取绘制项目的信息

有关更多信息,请查看