#include <QtGui>
int main(int argc, char *argv[])
{
model.
setHeaderData(0,Qt
::Horizontal,
QObject::tr("No."));
model.
setHeaderData(1,Qt
::Horizontal,
QObject::tr("Message"));
model.
setHeaderData(2,Qt
::Horizontal,
QObject::tr("Begin"));
model.
setHeaderData(3,Qt
::Horizontal,
QObject::tr("End"));
tree.setModel(&model);
tree.setColumnWidth(0,30);
tree.setColumnWidth(1,410);
tree.setColumnWidth(2,105);
tree.setColumnWidth(3,85);
tree.setRootIsDecorated(false);
tree.setAlternatingRowColors(true);
tree.setSortingEnabled(true);
tree.sortByColumn(2, Qt::DescendingOrder);
tree.show();
return app.exec();
}
#include <QtGui>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QStandardItemModel model(0, 4);
model.setHeaderData(0,Qt::Horizontal,QObject::tr("No."));
model.setHeaderData(1,Qt::Horizontal,QObject::tr("Message"));
model.setHeaderData(2,Qt::Horizontal,QObject::tr("Begin"));
model.setHeaderData(3,Qt::Horizontal,QObject::tr("End"));
model.setItem(0, 0, new QStandardItem("1"));
model.setItem(0, 1, new QStandardItem("Error 1"));
model.setItem(0, 2, new QStandardItem("09-12-2010, 14:00"));
model.setItem(0, 3, new QStandardItem("09-12-2010, 14:25"));
model.setItem(1, 0, new QStandardItem("2"));
model.setItem(1, 1, new QStandardItem("Error 2"));
model.setItem(1, 2, new QStandardItem("09-12-2010, 12:00"));
model.setItem(1, 3, new QStandardItem("09-12-2010, 14:25"));
QTreeView tree;
tree.setModel(&model);
tree.setColumnWidth(0,30);
tree.setColumnWidth(1,410);
tree.setColumnWidth(2,105);
tree.setColumnWidth(3,85);
tree.setRootIsDecorated(false);
tree.setAlternatingRowColors(true);
tree.setSortingEnabled(true);
tree.sortByColumn(2, Qt::DescendingOrder);
tree.show();
return app.exec();
}
To copy to clipboard, switch view to plain text mode
Bookmarks