PDA

View Full Version : QTreeWidget ui was not declared



hacquerqop
12th July 2018, 14:31
hey this is my code and It says that 'ui' was not declared

Dialog::Dialog(QWidget *parent) :
QDialog(parent),
ui(new Ui::Dialog)
{
ui->setupUi(this);

ui->treeWidget->setColumnCount(2); //and it says there is a problem there too about ->treeWidget must point to class/struct/pointer
AddRoot("hello", "world");
}

Dialog::~Dialog()
{
delete ui;
}


void AddRoot(QString name, QString description)
{
QTreeWidgetItem *itm = new QTreeWidgetItem (ui->treeWidget);

itm->setText(0, name);
itm->setText(1, description);
ui->treeWidget->addTopLevelItem(itm);

}

d_stranz
12th July 2018, 17:03
Did you add a QTreeWidget class instance into your Dialog.ui file named "treeWidget" when you used Qt Designer to define your dialog's UI?

And use CODE tags when posting source code. See my signature block below.