www.pudn.com > treeView.rar > main.cpp, change:2011-03-13,size:1912b


#include <QtGui/QApplication> 
#include "mainwindow.h" 
#include <QTextCodec> 
#include <QObject> 
#include <QUndoView> 
int main(int argc, char *argv[]) 
{ 
    QApplication a(argc, argv); 
    QTextCodec::setCodecForTr(QTextCodec::codecForName("GBK")); 
 
    MainWindow w; 
    w.show(); 
    QListWidget *widget = new QListWidget; 
   // QListWidget *widget_2 = new QListWidget(widget); 
 
    QListWidgetItem *item = new QListWidgetItem; 
    QListWidgetItem *item1 = new QListWidgetItem; 
    QListWidgetItem *item2 = new QListWidgetItem; 
    item1->setSizeHint(QSize(70,70)); 
    item->setIcon(QIcon(QPixmap("1000.jpg").scaled(40,40))); 
    item1->setIcon(QIcon(QPixmap("1000.jpg").scaled(70,40))); 
   // item->setFlags(Qt::ItemIsEditable); 
    item->setText("<html>ӭ</html>"); 
    //widget.setModel(model); 
   // widget_2->addItem(item); 
    //widget_2->setGeometry(0,0,1000,20); 
   widget->setIconSize(QSize(40,40)); 
    QLabel *label = new QLabel; 
  //  widget_2->setFrameStyle(QFrame::NoFrame); 
//    QList<QWidget *> widgets =widget.findChildren<QWidget *>(); 
//    foreach(QWidget *widget ,widgets) 
//    { 
//       // widget->icon().pixmap(40,40); 
//      //  widget->setMinimumSize(60,60); 
 
//        qDebug()<<"have in "; 
//    } 
    label->setText("<html>ӭ></html>"); 
    widget->addItem(item2); 
    widget->addItem(item); 
    widget->addItem(item1); 
    label->setMinimumHeight(80); 
      widget->setItemWidget(item,label); 
 
 
 
 
    widget->show(); 
 
//    QStandardItemModel *model = new QStandardItemModel(4,2  ); 
//       QStandardItem *item2 = new QStandardItem("bluetooth"); 
//       model->setItem(0,item2); 
//    QUndoView view; 
//    view.setWindowTitle("view"); 
//    view.setCleanIcon(QIcon(QPixmap("1000.jpg"))); 
//    view.setEmptyLabel("111111111111111"); 
//    view.setModel(model); 
//    view.show(); 
    return a.exec(); 
}