简单示例, QTreeView加进度条

#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();
}

你可能感兴趣的:(简单示例, QTreeView加进度条)