[Solved] Disable QStringListModel
-
Hello gang: I am able to present a list in a view. It is editable, and has a sliding "elevator" to adjust the view. I want to disable the editable characteristic, without disabling the elevator.
@
QAbstractItemModel *model = new QStringListModel(textList);
QListView *view = new QListView;
QVBoxLayout *layout = new QVBoxLayout;
view->setModel(model);
layout->addWidget(view);
window->setLayout(layout);
window->setFixedWidth(875);
window->setFixedHeight(800);
window->setAttribute(Qt::WA_DeleteOnClose);
window->show();
@I tried view->setDisabled(1), and that disabled editing, but also disabled the elevator.
Thank you.
-
Hi,
In order to make the view as non editable you can try:@view->setEditTriggers(QAbstractItemView::NoEditTriggers);@
you can have a look at "QAbstractItemView Class Reference":http://qt-project.org/doc/qt-4.8/qabstractitemview.html#editTriggers-prop and "EditTrigger":http://qt-project.org/doc/qt-4.8/qabstractitemview.html#EditTrigger-enum
-
Thank you Sam -- that is perfect!
-
You are most welcome my friend :)