PDA

View Full Version : Mysql query question



twells55555
29th June 2007, 23:02
Hi,

I'm trying to write some code to query a Mysql database and then provide next/previous buttons to cycle through the response if there are more than one record returned. I am using the windows version of Qt 4.2.

I am able to query and retrieve results from the database without any problem using

while( query.next())
{
.....
}

My problem is that I have not been able to get the code to "pause" after displaying a record until the user presses either the next or previous button. My futile attempts have either locked up the program in an endless loop or have done nothing, which resulted in all the returned records being quickly cycled through and only the last record viewable to the user.
Any suggestions on how to complete my record "browser" code would be appreciated. And why did they do away with the databrowser from Qt3 anyway?

Thanks in advance,

Tim

jacek
29th June 2007, 23:41
My problem is that I have not been able to get the code to "pause" after displaying a record until the user presses either the next or previous button.
You can't "pause" anything in an event-driven application or you get an unresponsive GUI. So instead of using a while loop, you have to store that query object in some safe place and write a method that will retrieve next record after user clicks a button. Instead of enforcing program flow, you just wait for an event and do your job.


And why did they do away with the databrowser from Qt3 anyway?
Because there's QDataWidgetMapper instead.