Skip to content
Snippets Groups Projects
Commit 5ed32cfd authored by tobiglaser's avatar tobiglaser
Browse files

Simplify ListItem, add ReadMe entry

parent e5bb24ba
No related branches found
No related tags found
No related merge requests found
#include <QListWidgetItem>
#include "control.h" #include "control.h"
#include "myListItem.h" #include "myListItem.h"
...@@ -28,9 +29,15 @@ void Control::onListChange() ...@@ -28,9 +29,15 @@ void Control::onListChange()
{ {
auto vec = model.getVec(); auto vec = model.getVec();
view.qList->clear(); // This could use some more precision, but whatever. view.qList->clear(); // This could use some more precision, but whatever.
for (auto &&i : vec) for (auto &&text : vec)
{ {
myListItem *li = new myListItem(i); // Using standard QListWidgetItem
QListWidgetItem *li = new QListWidgetItem;
li->setText(text.c_str());
// Or using our own subclass:
//myListItem *li = new myListItem(text);
view.qList->addItem(li); view.qList->addItem(li);
} }
} }
\ No newline at end of file
...@@ -14,6 +14,14 @@ Uses `QPushButton` and `QLineEdit`. ...@@ -14,6 +14,14 @@ Uses `QPushButton` and `QLineEdit`.
Special here is the division of functionality between view MainWindow and control Control. Special here is the division of functionality between view MainWindow and control Control.
It is not shown here, but when using a *model* it doesn't have to be a `QObject` and can thus be fully independend from the Qt Framework. It is not shown here, but when using a *model* it doesn't have to be a `QObject` and can thus be fully independend from the Qt Framework.
## ModelViewList
Add and remove Items inside a model and display them in the view.
Uses `QListWidget`, `QListWidgetItem`, `QPushButton` and `QLineEdit`.
Special here is the representation of a model list in a different view list as well their modification.
It is also shown how an own subclass of `QListWidgetItem` could be used instead of the original.
Different `slots` are defined, as well as one `signal`, although they don't use parameters.
# Building # Building
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment