Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
Qt Examples
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Glaser
Qt Examples
Commits
5ed32cfd
Commit
5ed32cfd
authored
Jun 14, 2022
by
tobiglaser
Browse files
Options
Downloads
Patches
Plain Diff
Simplify ListItem, add ReadMe entry
parent
e5bb24ba
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
ModelViewList/control.cpp
+9
-2
9 additions, 2 deletions
ModelViewList/control.cpp
README.md
+8
-0
8 additions, 0 deletions
README.md
with
17 additions
and
2 deletions
ModelViewList/control.cpp
+
9
−
2
View file @
5ed32cfd
#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
This diff is collapsed.
Click to expand it.
README.md
+
8
−
0
View file @
5ed32cfd
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
sign in
to comment