首页 > 其他 > 详细

用QComboBox实现tree状结构(QComboBox居然欧setView函数)

时间:2015-12-22 21:08:08      阅读:481      评论:0      收藏:0      [点我收藏+]

实现的效果图如下: 
技术分享

#include "mainwindow.h" 
#include <QApplication> 
#include <QTreeView> 
#include <QFileSystemModel> 
#include <QComboBox> 
#include <QDir>

int main(int argc, char *argv[]) 
{

QApplication a(argc, argv);
MainWindow w;
// 创建文件系统模型
QFileSystemModel *model = new QFileSystemModel(&w);
// 指定要监视的目录
model->setRootPath(QDir::currentPath());
QTreeView *tree = new QTreeView(&w);
tree->setModel(model);
tree->setRootIndex(model->index(QDir::currentPath()));
QComboBox *b = new QComboBox(&w);
b->resize(400, 20);
b->setView(tree);
b->setModel(model);
b->show();

w.show();

return a.exec();

} 
///////完

http://blog.csdn.net/u011915578/article/details/47783577

用QComboBox实现tree状结构(QComboBox居然欧setView函数)

原文:http://www.cnblogs.com/findumars/p/5068071.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!