Question

I have a database, which tables should viewed in a widget. Seems simple, but I can't decide what to du or use.

Each row of the table should be viewed as one list view item, for instance, imagine table with this fields: id, title, content, date, number.

I need to view it as a list view (not hard-coded, it may also be another thing, if it is possible or better), and the label of the list view item should be the title field. But when the user clicks or double clicks on that item it should open all the contents of the current row in a separate widget. The all of these can be implemented easily by me, but I can't understand what to use: QListView with its model, or QListWidget? Or maybe QSqlTableModel? The last one is unfamiliar to me, I can read about from documentation, but if you have heard or met some kind things/applications, please provide a better solution for described problem.

Hope I could explain my problem correctly, Thanks in advance.

Was it helpful?

Solution

Have you read about model/view programming in Qt? Basically you should use some model (QSqlTableModel, QSqlQueryModel, QSqlRelationalTableModel or create your own) an then attach it to QListView or QListWidget.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top