Posted on 2011-07-25 22:04
RTY 阅读(1290)
评论(0) 编辑 收藏 引用 所属分类:
Qt 、
C/C++ 、
转载随笔
#include <QApplication>
#include <QLineEdit>
#include <qDebug>
#include <QTime>
#include <QTreeWidget>
#include <QStringList>
#include <QItemDelegate>
#include <QProgressBar>
class ImageDelegate : public QItemDelegate
{
public:
ImageDelegate(QObject *parent = 0):QItemDelegate(parent){};
QWidget *createEditor(QWidget *parent, const QStyleOptionViewItem &option,
const QModelIndex &index) const
{
QProgressBar *progress = new QProgressBar(parent);
progress->setValue(20);
return progress;
};
};
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QTreeWidget tree;
tree.setColumnCount(2);
tree.setHeaderLabels(QStringList() << "colum");
tree.setItemDelegate(new ImageDelegate(&tree));
QTreeWidgetItem *item1 = new QTreeWidgetItem(&tree);
item1->setIcon(0, QIcon("E:\\Audio_MIME.ico"));
tree.openPersistentEditor(item1);
QTreeWidgetItem *item2 = new QTreeWidgetItem(&tree);
item2->setText(0, "aaaa");
tree.show();
return a.exec();
}