resetting entire model by setting to a different value
This commit is contained in:
@@ -23,11 +23,6 @@ Window {
|
|||||||
model: networksModel
|
model: networksModel
|
||||||
width: 100
|
width: 100
|
||||||
height: 1000
|
height: 1000
|
||||||
// model: ListModel {
|
|
||||||
// ListElement { name: "Item 1"; value: 10 }
|
|
||||||
// ListElement { name: "Item 3"; value: 20 }
|
|
||||||
// ListElement { name: "Item 3"; value: 30 }
|
|
||||||
// }
|
|
||||||
|
|
||||||
delegate: Item {
|
delegate: Item {
|
||||||
height: 20
|
height: 20
|
||||||
|
|||||||
+3
-3
@@ -50,18 +50,18 @@ QVariant NetworksModel::data(const QModelIndex &index, int role) const
|
|||||||
|
|
||||||
void NetworksModel::scan()
|
void NetworksModel::scan()
|
||||||
{
|
{
|
||||||
beginInsertRows(QModelIndex(), this->rowCount(), this->rowCount());
|
beginResetModel();
|
||||||
|
|
||||||
QList<Network> networks = this->m_networkScanner.scanForNetworks();
|
QList<Network> networks = this->m_networkScanner.scanForNetworks();
|
||||||
for (const Network& network: networks)
|
for (const Network& network: networks)
|
||||||
{
|
{
|
||||||
qDebug() << "Got network: " << network.name() << Qt::endl;
|
qDebug() << "Got network: " << network.name() << Qt::endl;
|
||||||
this->m_networks << network;
|
|
||||||
}
|
}
|
||||||
|
this->m_networks = networks;
|
||||||
|
|
||||||
qDebug() << "now have " << this->m_networks.size() << Qt::endl;
|
qDebug() << "now have " << this->m_networks.size() << Qt::endl;
|
||||||
|
|
||||||
endInsertRows();
|
endResetModel();
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> NetworksModel::roleNames() const
|
QHash<int, QByteArray> NetworksModel::roleNames() const
|
||||||
|
|||||||
Reference in New Issue
Block a user