what a bug...think through how things work to figure it out
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE QtCreatorProject>
|
||||
<!-- Written by QtCreator 12.0.2, 2024-02-08T09:05:49. -->
|
||||
<!-- Written by QtCreator 12.0.2, 2024-02-08T15:13:31. -->
|
||||
<qtcreator>
|
||||
<data>
|
||||
<variable>EnvironmentId</variable>
|
||||
|
||||
@@ -11,6 +11,7 @@ Window {
|
||||
|
||||
signal scanNetworks()
|
||||
|
||||
ColumnLayout {
|
||||
Button {
|
||||
id: scanbutton
|
||||
text: "Scan for networks"
|
||||
@@ -20,10 +21,11 @@ Window {
|
||||
ListView {
|
||||
id: listview
|
||||
model: networksModel
|
||||
anchors.fill: parent
|
||||
width: 100
|
||||
height: 1000
|
||||
// model: ListModel {
|
||||
// ListElement { name: "Item 1"; value: 10 }
|
||||
// ListElement { name: "Item 2"; value: 20 }
|
||||
// ListElement { name: "Item 3"; value: 20 }
|
||||
// ListElement { name: "Item 3"; value: 30 }
|
||||
// }
|
||||
|
||||
@@ -32,8 +34,9 @@ Window {
|
||||
required property string name
|
||||
|
||||
Text {
|
||||
text: parent.name
|
||||
text: parent.name
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+7
-1
@@ -28,12 +28,18 @@ int NetworksModel::rowCount(const QModelIndex &parent) const
|
||||
|
||||
QVariant NetworksModel::data(const QModelIndex &index, int role) const
|
||||
{
|
||||
if (index.row() < 9 || index.row() >= this->m_networks.count())
|
||||
if (index.row() < 0 || index.row() >= this->m_networks.count())
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
if (!index.isValid())
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
const Network& network = this->m_networks.at(index.row());
|
||||
qDebug() << "role: " << role << " vs. " << NameRole;
|
||||
qDebug() << "network: " << network.name();
|
||||
if (role == NameRole)
|
||||
{
|
||||
return network.name();
|
||||
|
||||
Reference in New Issue
Block a user