qabstractlistmodel

PyQt QWidget in QAbstractListModel gets deleted with QSortFilterProxyModel

99封情书 提交于 2019-12-08 02:03:51
问题 I need to populate a listview with widgets, then have a custom proxyfilter work with it. Without the filter it works great, when active it seems to delete the widgets attach to the model. It shows up fine showing all items, filtering works but when erasing the filter, when hidden widgets should be shown again following error gets thrown: custom_widget.setGeometry(option.rect) RuntimeError: underlying C/C++ object has been deleted Tried not using QVariant and going the internalPointer route

QAbstractListModel insertRows not working properly

时间秒杀一切 提交于 2019-12-07 09:17:51
问题 I have a subclass of QAbstractListModel and attached this model subclass with GridView. When I remove rows from my subclass, the GridView gets updated but when I insert rows in the model the GridView does not gets updated. I have implemented the removeR I have a very simple subclass of QAbstractListModel and I have attached with it a QML GridView. I have two buttons Add/Remove on the GUI. Pressing Add adds a string to the model and gui updated and pressing remove removes last string from the

Sort a QAbstractListModel derived model by role in QML ListView

Deadly 提交于 2019-12-07 04:58:55
问题 I've created a QAbstractListModel derived model based on an underlying QHash. Since I need to use the model in QML, I cannot make use of the sorting functionality Qt widgets and views have integrated. I tried using a QSortFilterProxyModel but it doesn't seem to work with my model. Getting the model to properly work in QML wasn't tedious enough, and now I am stuck on sorting. Any suggestions are appreciated. Here is the model source: typedef QHash<QString, uint> Data; class NewModel : public

base class 'QAbstractListModel' has private copy constructor

。_饼干妹妹 提交于 2019-12-06 03:32:17
问题 I have a QT QML project. (still very small) I started by binding a listview on my UScenario model, by subclassing QAbstractListModel and it worked fined. Now, each UScenario has a list of UTask , which also have a list of UCondition (so, Utask also subclasses QAbstractListModel ). But then, QT Creator gives me an error: Core/Tasks/utask.h:6: erreur : base class 'QAbstractListModel' has private copy constructor class UTask: public QAbstractListModel ^ So I'm not sure where is my problem. I

Use a QAbstractListModel in another one

巧了我就是萌 提交于 2019-12-06 02:09:20
I have an issue while trying to develop a data model for my application with Qt/QML. I already used a QAbstractListModel to be able to pass customs data model from C++ to QML and it worked like a charm with simple model (such as a model based on strings and bools). But now I need to build a more difficult model and I was wondering if it was possible to use a QAbstractListModel inside another QAbstractListModel . Let me explain myself. I have a data model called model_A build like that : model_A.h: #ifndef MODEL_A_H #define MODEL_A_H #include <QAbstractListModel> #include <QList> class model_A

Sort a QAbstractListModel derived model by role in QML ListView

和自甴很熟 提交于 2019-12-05 07:00:05
I've created a QAbstractListModel derived model based on an underlying QHash. Since I need to use the model in QML, I cannot make use of the sorting functionality Qt widgets and views have integrated. I tried using a QSortFilterProxyModel but it doesn't seem to work with my model. Getting the model to properly work in QML wasn't tedious enough, and now I am stuck on sorting. Any suggestions are appreciated. Here is the model source: typedef QHash<QString, uint> Data; class NewModel : public QAbstractListModel { Q_OBJECT Q_PROPERTY(int count READ count NOTIFY countChanged) public: NewModel

base class 'QAbstractListModel' has private copy constructor

老子叫甜甜 提交于 2019-12-04 08:38:57
I have a QT QML project. (still very small) I started by binding a listview on my UScenario model, by subclassing QAbstractListModel and it worked fined. Now, each UScenario has a list of UTask , which also have a list of UCondition (so, Utask also subclasses QAbstractListModel ). But then, QT Creator gives me an error: Core/Tasks/utask.h:6: erreur : base class 'QAbstractListModel' has private copy constructor class UTask: public QAbstractListModel ^ So I'm not sure where is my problem. I tried reading the doc about QAbstractListModel vs QAbstractItemModel , but I have no clue. I also tried to

Qt : setData method in a QAbstractItemModel

蹲街弑〆低调 提交于 2019-12-01 17:47:52
问题 I'm new to model view and I have been following this tutorial while checking the documentation at the same time and I stumbled upon this little detail : The code of the tutorial which can be downloaded here has in the QAbstractItemModel class (here QAbstractListModel) the setData method which code is : def setData(self, index, value, role = QtCore.Qt.EditRole): if role == QtCore.Qt.EditRole: row = index.row() color = QtGui.QColor(value) if color.isValid(): self.__colors[row] = color self

Qt : setData method in a QAbstractItemModel

依然范特西╮ 提交于 2019-12-01 17:23:26
I'm new to model view and I have been following this tutorial while checking the documentation at the same time and I stumbled upon this little detail : The code of the tutorial which can be downloaded here has in the QAbstractItemModel class (here QAbstractListModel) the setData method which code is : def setData(self, index, value, role = QtCore.Qt.EditRole): if role == QtCore.Qt.EditRole: row = index.row() color = QtGui.QColor(value) if color.isValid(): self.__colors[row] = color self.dataChanged.emit(index, index) return True return False According to the explanations in the tutorial and

QListView with QAbstractListModel shows an empty list

房东的猫 提交于 2019-12-01 04:43:14
I have created a very simple example of QListView with a custom QAbstractListModel . The QListView is displayed but it is empty. What am I doing wrong? Code: #include <QListView> #include <QAbstractListModel> #include <QApplication> class DataModel: public QAbstractListModel { public: DataModel() : QAbstractListModel() {} int rowCount( const QModelIndex & parent = QModelIndex() ) const { return 2; } QVariant data( const QModelIndex & index, int role = Qt::DisplayRole ) const { return "a"; } }; int main( int argc, char **argv) { QApplication app(argc, argv, true); QListView *lv = new QListView(