c++ - Requires 2 right clicks to switch context menus among items? -
code below
#include <qtwidgets> #include <qglwidget> int main(int argc, char *argv[]) { qapplication a(argc, argv); qmainwindow w; w.setcentralwidget(new qglwidget(&w)); // w.setcentralwidget(new qwidget(&w)); qtreewidget* tree = new qtreewidget(&w); qtreewidgetitem* item0 = new qtreewidgetitem(tree, qstringlist("a")); qtreewidgetitem* item1 = new qtreewidgetitem(tree, qstringlist("b")); tree->setcontextmenupolicy(qt::customcontextmenu); qobject::connect(tree, &qtreeview::customcontextmenurequested, [](){ qmenu menu; menu.addaction("a"); menu.exec(qcursor::pos()); }); qdockwidget* dock = new qdockwidget("tree", &w); dock->setwidget(tree); w.adddockwidget(qt::leftdockwidgetarea, dock); w.show(); return a.exec(); }
compile , run it. requires 2 right clicks switch context menus among items. however, if change qglwidget
qwidget
. fine. 1 right click can switch context menus among items. bugs??? lot.
some observations:
- switch positions of tree , gl widget ok, i.e. set tree central widget , gl widget 1 in dock.
it seems right click event goes central widget , blocked gl widget.
Comments
Post a Comment