Qt-embedded-interest Archive, November 2006
problems with QTreeWidget
Message 1 in thread
Hello everybody,
On my form I have a QTreeWidget element that gets its items from a certain
list and displays them in a hierarchical structure.
What I want to do is, at right click on any of those elements in the tree to
open up a sort of context menu that will contain some actions. I have to
keep in mind which element was click. The popup menu should appear ONLY when
I right click o an item in the tree, not the tree.
I was thinking of using mouse events, or reimplementing the function
mousePressed event maybe. But how can that work only for an item in the
tree?
Any advices about how I should implement this?
I created a new class derived from QTreeWidget and there reimplemented the
mousePressEvent(QMouseEvent *event) method, which constructs my pop up menu.
I added this new custom widget to my form using Promote to Custom widget and
giving as a header the header of this new created class.
And here is where I get the troubles: in my ui_myapplication.h appears
included the "derivedtreewidget.h" and declared the
QTreeWidget *derivedTreeWidget;
derivedTreeWidget *derived;.
In this point I get the errors:
missing '*' before ';'
UI_myapplication::derivedTreeWidget: missing storage-class or type
specifyers
UI_myapplication::derived: missing storage-class or type specifyers
which I really don't understand and I don't know how to repair.
Your help is most welcome.
Kind regards,
Consuela