c++ - Connect: No such Slot QTreeView -
i have inherited class maintree qtreeview
maintree.cpp file
void maintree::launchtree() { //tree launching connect(this, signal(customcontextmenurequested(const qpoint& )),this,slot(showcustomcontextmenu(const qpoint&))); } void maintree::showcustomcontextmenu(const qpoint &pos) { //add actions } but following error
qobject::connect: no such slot qtreeview::showcustomcontextmenu(const qpoint&) i not understand why, missing ??
definition of class maintree
class maintree : public qtreeview { public: maintree(); maintree(qwidget *parent = 0); public slots: private slots: void showcustomcontextmenu(const qpoint& pos); private: void launchtree(); };
you missing q_object macro out, try this:
class maintree : public qtreeview { q_object // ^^^^^ public: maintree(); maintree(qwidget *parent = 0); public slots: private slots: void showcustomcontextmenu(const qpoint& pos); private: void launchtree(); }; do not forget re-run qmake after regenerate moc files properly. make sure have moc include @ end of source code, or handle moc generation without that.
also, note if used qt 5.2 or later c++11 support, static assertion missing q_object macro, not runtime issues anymore. suggest follow if can.
Comments
Post a Comment