PDA

View Full Version : Executing a method after passing an object from a QDialog



JazzKatua
3rd January 2014, 22:23
Hi Every-1!

In my DVDCollection-Application I'm trying to pass a DVD-object made in a QDialog onto the main-application.


void WdgDvdsCollection::on_btnInputNewDvd_clicked()
{
DlgNewDvd dialog(this);
if (dialog.exec() == QDialog::Accepted)
{
Dvd d = dialog.tempDvd;
InsertNewDvd(d);
UpdateUi();
}
}

void WdgDvdsCollection::InsertNewDvd(Dvd d)
{
QSqlQuery query;
query.prepare("insert into tblDvds (title, publisher, nrOfDvds, genre) values (:title, :publisher, :nrOfDvds, :genre");
// rest of code in method
}



When I debug the application with F10, it enters the if-structure (so it executes dialog.exec() and 'accepts' the QDialog.
The Dvd-object d in the if-structure gets the values from the DVD in QDialog; so the DVD-object is also made.
But when I try to execute the next line (i.e. InsertNewDvd(d); ) with F10, the debugger steps over the line and the method doesn't get executed...

Any idea?

Grtz,
JazzKatua

anda_skoa
4th January 2014, 11:42
Have you tried stepping into the function?
Or do a simple qDebug() inside the function instead of executing the code step by step?

Cheers,
_

JazzKatua
4th January 2014, 12:36
Hi Anda_Skoa!

I think it was indeed F11 to enter the function. Now I realize that the QSqlQuery-function didn't get executed because it was created BEFORE the database-connection was opened(via db.open() ).
The reason I use F10 is because F11 enters ALL functions (e.g. QString-functions from Qt-libs) and is of no use for me.
I found the solution in Qt Creator: in Tools / Options in Debugger: GDB-tab => clicking 'Skip known frames when stepping'.
Thnx Anda_Skoa!