Bonjour à tous,
je suis actuellement sur un projet qui utilise Qt et je souhaiterais update une QListView automatiquement quand le model qu'elle affiche est modifié. Après quelques recherches j'ai vu que l'on pouvait connecter le signal QAbstractItemModel::dataChanged
au slot QAbstractItemView::update
j'ai donc écrit ceci
1 2 3 | // Ligne 41 de MainWindow.cpp QObject::connect(d_recipes, &QAbstractItemModel::dataChanged, d_ui->listView_Recipes, &QAbstractItemView::update); |
Mais cela me revoie cette magnifique erreur dont je ne comprend pas grand chose à la compilation
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 | src/MainWindow.cpp: Dans la fonction membre ‘void MainWindow::connectSlots()’: src/MainWindow.cpp:42:72: erreur : no matching function for call to ‘MainWindow::connect(RecipesModel&, void (QAbstractItemModel::*)(const QModelIndex&, const QModelIndex&, const QVector<int>&), QListView*&, <unresolved overloaded function type>)’ d_ui->listView_Recipes, &QAbstractItemView::update); ^ In file included from /usr/include/qt/QtWidgets/qwidget.h:38:0, from /usr/include/qt/QtWidgets/qmainwindow.h:37, from /usr/include/qt/QtWidgets/QMainWindow:1, from src/MainWindow.hpp:14, from src/MainWindow.cpp:11: /usr/include/qt/QtCore/qobject.h:196:36: note : candidate: static QMetaObject::Connection QObject::connect(const QObject*, const char*, const QObject*, const char*, Qt::ConnectionType) static QMetaObject::Connection connect(const QObject *sender, const char *signal, ^ /usr/include/qt/QtCore/qobject.h:196:36: note : no known conversion for argument 1 from ‘RecipesModel’ to ‘const QObject*’ /usr/include/qt/QtCore/qobject.h:199:36: note : candidate: static QMetaObject::Connection QObject::connect(const QObject*, const QMetaMethod&, const QObject*, const QMetaMethod&, Qt::ConnectionType) static QMetaObject::Connection connect(const QObject *sender, const QMetaMethod &signal, ^ /usr/include/qt/QtCore/qobject.h:199:36: note : no known conversion for argument 1 from ‘RecipesModel’ to ‘const QObject*’ /usr/include/qt/QtCore/qobject.h:475:32: note : candidate: QMetaObject::Connection QObject::connect(const QObject*, const char*, const char*, Qt::ConnectionType) const inline QMetaObject::Connection QObject::connect(const QObject *asender, const char *asignal, ^ /usr/include/qt/QtCore/qobject.h:475:32: note : no known conversion for argument 1 from ‘RecipesModel’ to ‘const QObject*’ /usr/include/qt/QtCore/qobject.h:213:43: note : candidate: template<class Func1, class Func2> static QMetaObject::Connection QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const typename QtPrivate::FunctionPointer<Func2>::Object*, Func2, Qt::ConnectionType) static inline QMetaObject::Connection connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, ^ /usr/include/qt/QtCore/qobject.h:213:43: note : template argument deduction/substitution failed: src/MainWindow.cpp:42:72: note : couldn't deduce template parameter ‘Func2’ d_ui->listView_Recipes, &QAbstractItemView::update); ^ In file included from /usr/include/qt/QtWidgets/qwidget.h:38:0, from /usr/include/qt/QtWidgets/qmainwindow.h:37, from /usr/include/qt/QtWidgets/QMainWindow:1, from src/MainWindow.hpp:14, from src/MainWindow.cpp:11: /usr/include/qt/QtCore/qobject.h:245:13: note : candidate: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<((int)(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, Func2) connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) ^ /usr/include/qt/QtCore/qobject.h:245:13: note : template argument deduction/substitution failed: src/MainWindow.cpp:42:72: note : candidate expects 3 arguments, 4 provided d_ui->listView_Recipes, &QAbstractItemView::update); ^ In file included from /usr/include/qt/QtWidgets/qwidget.h:38:0, from /usr/include/qt/QtWidgets/qmainwindow.h:37, from /usr/include/qt/QtWidgets/QMainWindow:1, from src/MainWindow.hpp:14, from src/MainWindow.cpp:11: /usr/include/qt/QtCore/qobject.h:254:13: note : candidate: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<(((int)(QtPrivate::FunctionPointer<Func2>::ArgumentCount) >= 0) && (! QtPrivate::FunctionPointer<Func2>::IsPointerToMemberFunction)), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const QObject*, Func2, Qt::ConnectionType) connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ /usr/include/qt/QtCore/qobject.h:254:13: note : template argument deduction/substitution failed: src/MainWindow.cpp:42:72: note : couldn't deduce template parameter ‘Func2’ d_ui->listView_Recipes, &QAbstractItemView::update); ^ In file included from /usr/include/qt/QtWidgets/qwidget.h:38:0, from /usr/include/qt/QtWidgets/qmainwindow.h:37, from /usr/include/qt/QtWidgets/QMainWindow:1, from src/MainWindow.hpp:14, from src/MainWindow.cpp:11: /usr/include/qt/QtCore/qobject.h:285:13: note : candidate: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<(QtPrivate::FunctionPointer<Func2>::ArgumentCount == (-1)), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, Func2) connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, Func2 slot) ^ /usr/include/qt/QtCore/qobject.h:285:13: note : template argument deduction/substitution failed: src/MainWindow.cpp:42:72: note : candidate expects 3 arguments, 4 provided d_ui->listView_Recipes, &QAbstractItemView::update); ^ In file included from /usr/include/qt/QtWidgets/qwidget.h:38:0, from /usr/include/qt/QtWidgets/qmainwindow.h:37, from /usr/include/qt/QtWidgets/QMainWindow:1, from src/MainWindow.hpp:14, from src/MainWindow.cpp:11: /usr/include/qt/QtCore/qobject.h:293:13: note : candidate: template<class Func1, class Func2> static typename QtPrivate::QEnableIf<(QtPrivate::FunctionPointer<Func2>::ArgumentCount == (-1)), QMetaObject::Connection>::Type QObject::connect(const typename QtPrivate::FunctionPointer<Func>::Object*, Func1, const QObject*, Func2, Qt::ConnectionType) connect(const typename QtPrivate::FunctionPointer<Func1>::Object *sender, Func1 signal, const QObject *context, Func2 slot, ^ /usr/include/qt/QtCore/qobject.h:293:13: note : template argument deduction/substitution failed: src/MainWindow.cpp:42:72: note : couldn't deduce template parameter ‘Func2’ d_ui->listView_Recipes, &QAbstractItemView::update); ^ make: *** [bin/tmp/MainWindow.o] Erreur 1 |
Je pense que c'est vraiment une erreur débile mais elle me passe sous le nez donc voilà.
PS : le code est disponible en entier sur github
+0
-0