Search code examples
qtqsqldatabase

How to get signal of qsqldatabase?


I want signal emitted by qsqldatabse object

Eg: I have Qsqldatabase db;

connect (&db, SIGNAL(signal_like_exec()), this, SLOT(any_slot()));

I'm not getting signal in connect() for db

Is there any way to do this?


Solution

  • QSqlDatabase class does not have signals or slots. Qt event loop and the database are not related in anyway. You only perform operations on data and that's it! Subclassing QSqlDatabase and creating custom signals is a bad idea because you wouldn't be able to create and open a connection to the database. So just call your function after db.open() returns true.