Sorry for delay for reply i was on hollyday.
first the frees.txt file have 11 string items on the row seperated with tabs.
see example.
Koolstofstaal 350-850 EC 5 3 Ja Contour frezen 80-100 0.015-0.030 max. 2xD <2.5
Gereedschapstaal 800-1200 EC 8 3 Ja Gleuf frezen 80-100 0.015-0.030 max. 2xD <2.5
These file will be updated with 600 rows.
In my zoekDialog i have 5 comboboxes in each combobox different items.
When i choose items i want to show the items in Mainwindow lineedits.
example:
combobox 1 = Koolstofstaal
combobox 2 = EC
combobox 3 = 5
combobox 4 = 3
combobox 5 = Contour Frezen
The rest of the row in frees.txt must fill up in the other Mainwindow lineedits.
The problem is the iterator on stringlist show only 1 string item.
Normally i want to use in if 5 statements but the pick only 1 the first one
See example.
if ( mat == dlg.matComboBox->currentText() && frees == dlg.freesComboBox->currenText() && etc ... ) every statement must be true.
see MainWindow.cpp
void MainWindow::zoek()
{
zoekDialog dlg(this);
if( dlg.
exec() == QDialog::Accepted ) { // Open a Dialog with 5 Comboboxen filled with items.
QString treksterkte, koeling, voedingpertand, snijsnelheid, snedediepte, snedebreedte;
QString mat
= dlg.
matComboBox->currentText
();
//Choose a item in the combobox and put in the string mat. QString frees
= dlg.
freesComboBox->currentText
();
QString tand
= dlg.
tandComboBox->currentText
();
QString dia
= dlg.
diaComboBox->currentText
();
QString bewrk
= dlg.
bewerkComboBox->currentText
();
QFile file("C:/Qt/Qt-prog/richtwaarden/frees.txt");
//Open the file with strings seperated with tabs. if( !file.
open(QFile::ReadOnly)) return;
do {
line = stream.readLine();
if(!line.isEmpty())
{
QListIterator<QString> i(frees); // Iterate over the Stringlist frees.
while (i.hasNext())
{
if ( mat == i.next()) // It search for that item in the Stringlist en put the item
leMateriaal->setText( mat ); // in the Mainwindow Lineedit.
if ( freestype == i.next())
leFrees->setText( freestype ); // This don't work
}
}
}while(!line.isEmpty());
file.close();
}
void MainWindow::zoek()
{
zoekDialog dlg(this);
if( dlg.exec() == QDialog::Accepted ) { // Open a Dialog with 5 Comboboxen filled with items.
QString treksterkte, koeling, voedingpertand, snijsnelheid, snedediepte, snedebreedte;
QString mat = dlg.matComboBox->currentText(); //Choose a item in the combobox and put in the string mat.
QString frees = dlg.freesComboBox->currentText();
QString tand = dlg.tandComboBox->currentText();
QString dia = dlg.diaComboBox->currentText();
QString bewrk = dlg.bewerkComboBox->currentText();
QFile file("C:/Qt/Qt-prog/richtwaarden/frees.txt"); //Open the file with strings seperated with tabs.
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); // Make a Stringlist
QListIterator<QString> i(frees); // Iterate over the Stringlist frees.
while (i.hasNext())
{
if ( mat == i.next()) // It search for that item in the Stringlist en put the item
leMateriaal->setText( mat ); // in the Mainwindow Lineedit.
if ( freestype == i.next())
leFrees->setText( freestype ); // This don't work
}
}
}while(!line.isEmpty());
file.close();
}
To copy to clipboard, switch view to plain text mode
B.T.W. i did this with QtSql and QTSqlQuerry no problem works fine.
see little example of code:
void MainWindow::zoek()
{
zoekDialog dlg(this);
if( dlg.
exec() == QDialog::Accepted ) {
QSqlQuery query
("SELECT * FROM frezen WHERE materiaal='" + dlg.
matComboBox->currentText
() + "'AND freesdiameter='" + dlg.
diaComboBox->currentText
() + "'AND freestype='" + dlg.
freesComboBox->currentText
() + "'AND aantaltanden='" + dlg.
tandComboBox->currentText
() + "'AND freesbewerking='" + dlg.
bewerkComboBox->currentText
() + "';");
if (query.next())
materiaal= query.value(0).toString();
leMateriaal
->setText
(materiaal
);
QString treksterkte
= query.
value(1).
toString();
leTrek->setText(treksterkte);
QString freestype
= query.
value(2).
toString();
leFrees->setText(freestype);
QString freesdiameter
= query.
value(3).
toString();
leDiam->setText(freesdiameter);
QString aantaltanden
= query.
value(4).
toString();
leAantal->setText(aantaltanden);
QString koeling
= query.
value(5).
toString();
leKoeling->setText(koeling);
QString freesbewerking
= query.
value(6).
toString();
leFreesb->setText(freesbewerking);
QString snijsnelheid
= query.
value(7).
toString();
leSnijsnelheid->setText(snijsnelheid);
QString voedingpertand
= query.
value(8).
toString();
leAanzet->setText(voedingpertand);
QString snedediepte
= query.
value(9).
toString();
leSneded->setText(snedediepte);
QString snedebreedte
= query.
value(10).
toString();
leSnedeb->setText(snedebreedte);
void MainWindow::zoek()
{
zoekDialog dlg(this);
if( dlg.exec() == QDialog::Accepted ) {
QString materiaal;
QSqlQuery query("SELECT * FROM frezen WHERE materiaal='" + dlg.matComboBox->currentText() + "'AND freesdiameter='" + dlg.diaComboBox->currentText() + "'AND freestype='" + dlg.freesComboBox->currentText() + "'AND aantaltanden='" + dlg.tandComboBox->currentText() + "'AND freesbewerking='" + dlg.bewerkComboBox->currentText() + "';");
if (query.next())
materiaal= query.value(0).toString();
leMateriaal->setText(materiaal); QString treksterkte = query.value(1).toString();
leTrek->setText(treksterkte);
QString freestype = query.value(2).toString();
leFrees->setText(freestype);
QString freesdiameter = query.value(3).toString();
leDiam->setText(freesdiameter);
QString aantaltanden = query.value(4).toString();
leAantal->setText(aantaltanden);
QString koeling = query.value(5).toString();
leKoeling->setText(koeling);
QString freesbewerking = query.value(6).toString();
leFreesb->setText(freesbewerking);
QString snijsnelheid = query.value(7).toString();
leSnijsnelheid->setText(snijsnelheid);
QString voedingpertand = query.value(8).toString();
leAanzet->setText(voedingpertand);
QString snedediepte = query.value(9).toString();
leSneded->setText(snedediepte);
QString snedebreedte = query.value(10).toString();
leSnedeb->setText(snedebreedte);
To copy to clipboard, switch view to plain text mode
Maby i must stick with QTSql.
Thaks in advance.
Bookmarks