walala123456
13th June 2008, 13:04
here is my codes:
#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc,argv);
QDirModel* model = new QDirModel();
QTreeView* view = new QTreeView();
view->setModel(model);
QComboBox* combo = new QComboBox();
combo->setView(view);
combo->setModel(model);
combo->show();
QString root = "D:/";/*QDir::rootPath();*/
combo->setRootModelIndex((static_cast<QDirModel*>(combo->model()))->index(root));
app.exec();
}
the ComboBox always show the root as "C:",how can I set it to the "D:"?
I'm using Qt 4.4.0.If you use the old version such as 4.3.1,there will be a few other bugs.
thanks a lot.
#include <QtGui>
int main(int argc, char **argv)
{
QApplication app(argc,argv);
QDirModel* model = new QDirModel();
QTreeView* view = new QTreeView();
view->setModel(model);
QComboBox* combo = new QComboBox();
combo->setView(view);
combo->setModel(model);
combo->show();
QString root = "D:/";/*QDir::rootPath();*/
combo->setRootModelIndex((static_cast<QDirModel*>(combo->model()))->index(root));
app.exec();
}
the ComboBox always show the root as "C:",how can I set it to the "D:"?
I'm using Qt 4.4.0.If you use the old version such as 4.3.1,there will be a few other bugs.
thanks a lot.