遍历QListWidget的item

void ReadRisingTide::connectFile()
{
	QString rising_path;
	rising_path = QFileDialog::getOpenFileName(NULL, "请选择数据文件", QCoreApplication::applicationFilePath(), "CSV(*.CSV)");
	for (int j = 0; j < ui.listWidget->count(); j++)
	{
		QString itemPath = ui.listWidget->item(j)->text();
		if (itemPath == rising_path)
		{
			return;
		}
	}
	ui.listWidget->addItem(rising_path);

}

 

你可能感兴趣的:(QTDevelop)