struct AppsData {
QList<QIcon> icons;
QStringList name;
QStringList version;
QStringList publisher;
QStringList installLocation;
QStringList uninstallLocation;
};
void Test::setAppData(QList<QIcon> icons, QStringList names, QStringList versions, QStringList publishers, QStringList installLocations, QStringList uninstallLocations)
{
AppsData appsData;
appsData.icons = icons;
appsData.name = names;
appsData.version = versions;
appsData.publisher = publishers;
appsData.installLocation = installLocations;
appsData.uninstallLocation = uninstallLocations;
QVector<AppsData> dataVector;
dataVector.push_back(appsData);
}
我想在適當的列中顯示所有應用程序數據。獲取已安裝的應用程序數據問題
而且我試圖完成它無載體:
for (int i = 0; i < uninstallLocations.count(); i++) {
allApplicationsItem = new QTreeWidgetItem(allApplications);
allApplicationsItem->setText(0, names.at(i));
allApplicationsItem->setText(1, versions.at(i));
allApplicationsItem->setText(2, publishers.at(i));
allApplicationsItem->setText(3, installLocations.at(i));
allApplicationsItem->setText(4, uninstallLocations.at(i));
}
,但它不工作,該應用程序崩潰。
然後不要創建'vector.count()''QTreeWidgetItem's。結束爲錯字。 – LogicStuff
@LogicStuff 我改變了主要帖子。謝謝。如果不使用'vector.count()',那麼如何迭代vector? – Cobra91151
@ Cobra91151回答你的評論問題:你可以使用QVectorIterator(http://doc.qt.io/qt-5/qvectoriterator.html#QVectorIterator)。至於原始問題,你可以指定什麼'父母',你是什麼意思,它返回,但不是全部(只有5)'? – lpares12