Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Qt: model/view concept with text browser

I am writing an application in Qt with C++. In this application I have to display an amount of data in a text box.

Is there a way to use QTextEdit or QPlainTextEdit with the model/view concept in Qt? I only found list, tree, or table View classes with mvc functionality.

like image 846
ramón Avatar asked Oct 30 '22 23:10

ramón


2 Answers

Is there a way to use QTextEdit or QPlainTextEdit with the model/view concept in Qt?

No.

For using model/view concept you need use already existed classes which inherit QAbstractItemView (such as: QColumnView, QHeaderView, QListView, QTableView and QTreeView) or inherit your custom class.

like image 93
Gluttton Avatar answered Nov 15 '22 05:11

Gluttton


Have a look at the Qt documentation. There are the options you have: http://doc.qt.io/qt-4.8/model-view-programming.html

Models

QAbstractItemModel provides an interface to data that is flexible enough to handle views that represent data in the form of tables, lists, and trees. However, when implementing new models for list and table-like data structures, the QAbstractListModel and QAbstractTableModel classes are better starting points because they provide appropriate default implementations of common functions.

Views

QListView displays a list of items, QTableView displays data from a model in a table, and QTreeView shows model items of data in a hierarchical list. Each of these classes is based on the QAbstractItemView abstract base class.

Controller

QAbstractItemDelegate is the abstract base class for delegates in the model/view framework.

like image 33
holzkohlengrill Avatar answered Nov 15 '22 04:11

holzkohlengrill