Hello anyone,
I have Qt-4.2.3 on Windows XP
The problem is QStringList
I want to read a line with string items in QStringList through a Dialog .
I did this with QtSql and it works fine but i don't want to use QtSql.
I want to use a file.
mainwindow.cpp
oid MainWindow::zoek()
{
zoekDialog dlg(this);
if( dlg.
exec() == QDialog::Accepted ) {
QString treksterkte, koeling, snijsnelheid, voedingpertand, snedediepte, snedebreedte,
QString materiaal
= dlg.
matComboBox->currentText
();
QString freestype
= dlg.
freesComboBox->currentText
();
QString diameter
= dlg.
diaComboBox->currentText
();
QString tand
= dlg.
tandComboBox->currentText
();
QString bewerking
= dlg.
bewerkComboBox->currentText
();
QFile file("C:/Qt/Qt-prog/richtwaarden/frees.txt");
if( !file.
open(QFile::ReadOnly)) return;
do {
line = stream.readLine();
if(!line.isEmpty())
{
if(it != frees.end())
{
if ( *it == materiaal )
leMateriaal->setText(*it); //put the text in the linedit.
++it;
}
}
}while(!line.isEmpty());
file.close();
}
oid MainWindow::zoek()
{
zoekDialog dlg(this);
if( dlg.exec() == QDialog::Accepted ) {
QString treksterkte, koeling, snijsnelheid, voedingpertand, snedediepte, snedebreedte,
QString materiaal = dlg.matComboBox->currentText();
QString freestype = dlg.freesComboBox->currentText();
QString diameter = dlg.diaComboBox->currentText();
QString tand = dlg.tandComboBox->currentText();
QString bewerking = dlg.bewerkComboBox->currentText();
QFile file("C:/Qt/Qt-prog/richtwaarden/frees.txt");
if( !file.open(QFile::ReadOnly))
return;
QTextStream stream( &file);
QString line;
do {
line = stream.readLine();
if(!line.isEmpty())
{
QStringList frees = line.split('\t', QString::SkipEmptyParts);
QStringList::iterator it = frees.begin();
if(it != frees.end())
{
if ( *it == materiaal )
leMateriaal->setText(*it); //put the text in the linedit.
++it;
}
}
}while(!line.isEmpty());
file.close();
}
To copy to clipboard, switch view to plain text mode
This works but he only find one string materiaal.
I want to find all the string items wich i choose in the comboboxes in the zoekdialog.
Thanks in advance
Bookmarks