Not accessing widget outside the class
Hi
i m creating one dialog using designer...dialog conatins one treeWidget.
I m making this this dialog as public...
Ui::Dialog dlg;
In the construtor i m calling setupUi(this); its working....
but i want to use this treeWidget in other class...i m using obj of this class...
obj->dlg.treeWidget in other class...but its not working...where m i missing...
Re: Not accessing widget outside the class
Well, how exactly are you using it? Is it in other thread?
Is the dialog created( setupUi and all ) when you use it?
Could you post some relevant code?
Re: Not accessing widget outside the class
some code for this ...
//first file
#include "ui_Dialog.h"
Header file
public:
Ui::Dialog dlg;
cpp file
Constructor part of FIRST class
{
dlg.setupUi(this);
dlg.treeWidget->setColumnCount(2);
}
///Second class
header class
private:
FIRST *first;
//cpp file
void SECOND::func()
{
QTreeWidgetItem *pItem = NULL;
pItem = new QTreeWidgetItem(first->dlg.treeWidget);
pItem->setText(0,"root");
}
///But is not connecting to the FIRST class...not display text "root" in treeWidget ...why
Re: Not accessing widget outside the class
The problem is that you did not instantiate FIRST in the SECOND class.
You have to create FIRST to be able to use it like that. Something like:
first = new FIRST();
Re: Not accessing widget outside the class
i already instantialted like this in my class
first = new FIRST();
still it is not working....
Re: Not accessing widget outside the class
In the constructor of FIRST:
it is setupUi( this ) not dlg.setupUi( this ).
If you get any errors after replacing that, please post them
Re: Not accessing widget outside the class
Quote:
Originally Posted by
santosh.kumar
still it is not working....
What does "not working" exactly mean in this case? Does it compile?
Quote:
Originally Posted by
marcel
In the constructor of FIRST:
it is setupUi( this ) not dlg.setupUi( this ).
The original version was OK, as santosh.kumar uses the single inheritance approach.