Originally Posted by
restiz
Hello, i'm new in this community, my ask is the next
I'm have two forms, in one the users introduce a date with the class QDateEdit then, the user's click on a push button and he goes to a second form, when the user do click in the first from, the date store pass to second form how to qstring, i'm know transform the control qdate to qstring, but, i don't know how pass the variable that contain the date (qstring) to the second form, how i did this?
You can use http://doc.trolltech.com/4.1/qsettings.html is easy ....
is same as php session .....
/* write a value */
mydir = fileName.left(fileName.lastIndexOf("/"))+"/";
setter.setValue("LastDir",mydir);
/* read a value .... */
/* write a value */
QSettings setter;
mydir = fileName.left(fileName.lastIndexOf("/"))+"/";
setter.setValue("LastDir",mydir);
/* read a value .... */
QSettings setter;
QString fileName = QFileDialog::getSaveFileName(this, "Export PDF",QString(setter.value("LastDir").toString()), "*.pdf");
To copy to clipboard, switch view to plain text mode
You save int or string ecc...
int margin = settings.value("editor/wrapMargin").toInt();
Or moore difficult.... save all objekt to a list....
QList<QLineEdit *> textList = this->findChildren<QLineEdit *>();
and read
/* QLineEdit editable true */
for (int i=0;i<textList.size();i++){
obname
=QString(textList
[i
]->objectName
());
if (obname.startsWith("TABLENAME_")) { /* ID_CLIENTE*/
dbfieldname = obname.right(obname.size() - 8);
valutadata = textList[i]->text();
Box_att.
insert(loopnext
++,
QStringList() << dbfieldname << valutadata
);
/*qDebug() << "### dbfieldname" << dbfieldname << " pos " << loopnext; */
if (valutadata.size() < 1) {
vuoti++;
}
}
}
.....................
UpdateQuery::Iterator it;
for ( it = Box_att.begin(); it != Box_att.end(); ++it ) {
insertliner.append(sx);
}
QString update_ALL
= insertliner.
join(", ");
QString queryUpdate
= QString( "UPDATE TABLENAME SET %1 WHERE ID=%2" ).
arg( update_ALL ,
QString::number(idogg
) );
/*qDebug() << "### queryUpdate " << queryUpdate; */
/* QLineEdit editable true */
for (int i=0;i<textList.size();i++){
obname =QString(textList[i]->objectName());
if (obname.startsWith("TABLENAME_")) { /* ID_CLIENTE*/
dbfieldname = obname.right(obname.size() - 8);
valutadata = textList[i]->text();
Box_att.insert(loopnext++,QStringList() << dbfieldname << valutadata);
/*qDebug() << "### dbfieldname" << dbfieldname << " pos " << loopnext; */
if (valutadata.size() < 1) {
vuoti++;
}
}
}
.....................
QStringList insertliner;
UpdateQuery::Iterator it;
for ( it = Box_att.begin(); it != Box_att.end(); ++it ) {
QStringList itemsetter = it.value();
QString sx = QString(itemsetter.at(0))+"='"+QString(itemsetter.at(1))+"'";
insertliner.append(sx);
}
QString update_ALL = insertliner.join(", ");
QString queryUpdate = QString( "UPDATE TABLENAME SET %1 WHERE ID=%2" ).arg( update_ALL , QString::number(idogg) );
/*qDebug() << "### queryUpdate " << queryUpdate; */
To copy to clipboard, switch view to plain text mode
I update so sqltable and must no write fieldname or sql ... only pair objektname = (is filedname) and data grab from objekt...
Fileld name only write a objekt name (tablename_fieldname) on ui designer file....
Bookmarks