Hi,
i have a question is it possible to save and store data so that whenever the application starts it can be loaded by using QSqlTableModel..or by anyother QtSqls ??
Hi,
i have a question is it possible to save and store data so that whenever the application starts it can be loaded by using QSqlTableModel..or by anyother QtSqls ??
Yes, it is possible. Read about QSettings, especially about QSettings::registerFormat.
if you want use SQL just create a SQLite database and use it whenever you want.
the question i am asking doesnt directly corresponds with the heading of topic..but still it is somehow regarding the same problem so i will ask it here..
whats the problem in this piece of code..the table view changes from total white screen to a screen with a hash sign at the begiinning and whole white
Qt Code:
sqlModel->setTable("notes"); int row =0; sqlModel->insertRows(row,1); sqlModel->setData(sqlModel->index(row,0),topicValue); sqlModel->setData(sqlModel->index(row,1),dateValue); sqlModel->setData(sqlModel->index(row,2),dataValue); sqlModel->submitAll(); tableView->show();To copy to clipboard, switch view to plain text mode
i copied the above code from a book and it didnt worked ...i have modified the code a bit and now it shows the table in my desired orientation but without the datas in it..i will paste it here
Qt Code:
constructor { .. sqlModel->setHeaderData(0,Qt::Horizontal,"Topic"); sqlModel->setHeaderData(1,Qt::Horizontal,"Date"); sqlModel->setHeaderData(2,Qt::Horizontal,"Data"); sqlModel->insertColumns(column,3); .. } void NoteBook::addRecord() { sqlModel->insertRows(row,1); tableView->setModel(sqlModel); sqlModel->submitAll(); ++row; tableView->show(); }To copy to clipboard, switch view to plain text mode
In addRecord() where are the values of your 3 QVariants being set?
can u please come again..i didntunderstand...if u mean topicvalue ,datavalue and datevalue..then i have taken a line edit and taken an input from user and stored in it...
I jus debugged this piece of code and the compiler said no signal generated..
here topic is QlineEdit and i wanna see if the line changes so i can save the values of line to my variable...
Qt Code:
{topicValue = topic.text();} {dateValue = date.text();} {dataValue = data.text(); qDebug() << dateValue; }To copy to clipboard, switch view to plain text mode
Bookmarks