开发者

Can I add columns in a QListView in Qt?

Can I add columns in a QListView object??

here's something I found here:

model->setHeaderData( 0, Qt::Horizontal, "numéro" );
model->setHeaderData( 1, Qt::Horizontal, "prénom" );
model->setHeaderData( 2, Qt::Horizontal, "nom"    );
//...
model->setData( model->index( line, 0 ), contact->num(),    Qt::DisplayRole );
model->setData( model->index( line, 1 ), contact->prenom(), Qt::DisplayRole );
model->setData( model->index( line, 2 ), contact->no开发者_开发知识库m(),    Qt::DisplayRole );

Since I'm using Qt Creator 2.0.1, I figured my model would be:

ui->ObjectName->model()

The Code snippet was added in the main window constructor's implementation after the:

ui->setupUi(this);

The application builds successfully but I get a: "The program has unexpectedly finished." at runtime.

Any Ideas ? Thanks.


I don't believe QListView supports multiple columns. You can use a QTreeWidget instead, it supports multiple columns.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜