Hello. This is not exactly my problem, I have simplified it but it should be worth.

I have a QMainWindow with two QTreeWidgets.
I have subclassed QTreeWidgets: MyTree1 and MyTree2, each one has its own ContextMenu when you right click on.

Now I want to click on MyTree2 and in the ContextMenu I choose "Text of the first item" that it's used to debug and prints on console the text of the first QTreeWidgetItem of MyTree1.
That should be too easy to do but since QMainWindow has a (QWidget)centralwidget and you can't remove it I don't know how to do that.

It should be something like this:
Qt Code:
  1. #include "mytree2.h"
  2.  
  3. MyTree2::MyTree2(QWidget* parent)
  4. : QTreeWidget(parent)
  5. {
  6. [...]
  7. p = parent->parentWidget(); //since p is a pointer
  8. //to the parent widget which is centralwidget
  9. //I also use parentWidget() to point to QMainWindow
  10. }
  11.  
  12. MyTree2::debugFirst()
  13. {
  14. qDebug() << p->QTreeWidget1->topLevelItem(0)->text(0);
  15. }
To copy to clipboard, switch view to plain text mode 

But an error compiling in line 14 says that Class QWidget doesnt own a member called QTreeWidget1

So.. how could I do that?
I hope you guys understand me and I'm sorry if this question is too newbie for the newbie forum