我有在qtreewidget中插入数据和qprogress栏的功能。当函数从mainwindow构造函数调用时它工作正常但是当从全局指针调用函数时,变量数据被插入到所有相应的列中,但进度没有附加到treewidget的相应列。我的代码是 -
MainWindow *mainw; //global variable
MainWindow::MainWindow(QWidget *parent)
:QMainWindow(parent),ui(newUi::MainWindow)
{
ui->setupUi(this);
filltree();// work fine
}
void MainWindow::filltree()
{
QProgressBar *prgbar=new QProgressBar();
cities1 = new QTreeWidgetItem(ui->treeWidget);
cities1->settext(0,RAM1);
cities->settext(1,RAM2);
ui->treeWidget->setItemWidget(cities1,3,prgbar);
}
void funglobal()
{
mainw->filltree(); //problem is here progressbar not attached to column of row of treewidget
}