I'm having trouble adding QTreeItems to a QTreeWidget after subclassing it. The following code works fine, but no items appear in the treewidget.
xtreewidget.h
#include <QTreeWidget>
Q_OBJECT
public:
void redraw();
public slots:
private:
};
#include <QTreeWidget>
class xTreeWidget: public QTreeWidget {
Q_OBJECT
public:
xTreeWidget(QWidget *parent);
void redraw();
public slots:
private:
};
To copy to clipboard, switch view to plain text mode
xtreewidget.cpp
xTreeWidget
::xTreeWidget(QWidget *parent
) { redraw();
}
void xTreeWidget::redraw() {
//Doesn't Work
item1->setText(0,tr("item1"));
//This don't either.
addTopLevelItem(item2);
item2->setText(0,tr("item2"));
}
xTreeWidget::xTreeWidget(QWidget *parent) {
redraw();
}
void xTreeWidget::redraw() {
//Doesn't Work
QTreeWidgetItem *item1 = new QTreeWidgetItem(this);
item1->setText(0,tr("item1"));
//This don't either.
QTreeWidgetItem *item2 = new QTreeWidgetItem;
addTopLevelItem(item2);
item2->setText(0,tr("item2"));
}
To copy to clipboard, switch view to plain text mode
Any help would be greatly appreciated.
Bookmarks