Results 1 to 2 of 2

Thread: Mysql query question

  1. #1
    Join Date
    Apr 2007
    Posts
    10
    Qt products
    Qt4
    Platforms
    Windows

    Default Mysql query question

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Mysql query question

    Quote Originally Posted by twells55555 View Post
    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.

    Quote Originally Posted by twells55555 View Post
    And why did they do away with the databrowser from Qt3 anyway?
    Because there's QDataWidgetMapper instead.

Similar Threads

  1. MySQL starting problem
    By shamik in forum General Discussion
    Replies: 5
    Last Post: 25th April 2007, 07:20
  2. Qt 4.1.4 & Mysql 5 on Linux x64
    By bothapn in forum Installation and Deployment
    Replies: 7
    Last Post: 4th August 2006, 13:23
  3. Qt 4.1 OS on Windows & mysql
    By neeko in forum Installation and Deployment
    Replies: 10
    Last Post: 31st January 2006, 20:22

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.