Results 1 to 3 of 3

Thread: Execution order

  1. #1
    Join Date
    Apr 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Execution order

    Dear All

    I have written a small class called MYSQL_DB which deals with all the steps required for QMYSQL (QtSql) with the database parameters being passed from another class. The following function should disable all QPushButton's, print a line to QTextEdit telling the user that the database connection routine is running and then instantiate the MYSQL_DB class and call one of its methods.

    All this code works exactly as designed but with one major problem. The code at lines 4,5,6 and the QTextEdit->insertPlainText at line 15 does not run until the MYSQL_DB class has completed.

    I cannot understand why this should be. Cam anybody help me with this dilemma?

    Many thanks
    Ishtar


    Qt Code:
    1. void Dialog_Configure::connectDB(){
    2.  
    3. // Disable all buttons
    4. ui->buttonOK->setEnabled(false);
    5. ui->buttonCancel->setEnabled(false);
    6. ui->buttonConnect->setEnabled(false);
    7.  
    8. //Grab credentials from QLineEdit
    9.  
    10. QString DB_IPAddress = ui->lineIPAddress->text();
    11. int DB_PortAddress = ui->linePort->text().toInt();
    12. QString DB_UserName = ui->lineUserName->text();
    13. QString DB_Password = ui->linePassword->text();
    14.  
    15. ui->textEditDBStatusLog->insertPlainText("Connecting...\n\n"); // Add text to QTextEdit informing user of the initilised connection
    16.  
    17. // Instantiate an instance of MySQL_DB class
    18.  
    19. MySQL_DB connectionTest;
    20.  
    21. // Call connectionTest method of the MySQL_DB Class returning QString status
    22.  
    23. QString connectionStatus = connectionTest.connectionTest(DB_IPAddress, DB_PortAddress, DB_UserName, DB_Password);
    24.  
    25.  
    26. // Add SQL connection result into QTextEdit
    27.  
    28. ui->textEditDBStatusLog->insertPlainText(connectionStatus);
    29.  
    30.  
    31. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Aug 2006
    Posts
    221
    Thanks
    3
    Thanked 29 Times in 19 Posts

    Default Re: Execution order

    Hard to believe. Your lines 4 - 15 are executed long before 19. But you use designer created classes and I don't have too much experience with those. Does not make too much sense, but I'd try to add a 'processEvents' before line 19.

  3. #3
    Join Date
    Apr 2010
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Execution order

    Hi Kumosan

    Many thanks for your help. Using the following fixed my problem.

    Qt Code:
    1. qApp->processEvents();
    To copy to clipboard, switch view to plain text mode 

    Once again, thank you.

    Ishtar

Similar Threads

  1. Probleme d'execution Qt/XML
    By fhorizon in forum General Programming
    Replies: 2
    Last Post: 11th May 2009, 10:00
  2. execution in QT
    By adamatic in forum Qt Programming
    Replies: 4
    Last Post: 20th February 2009, 08:12
  3. Execution error
    By Shuchi Agrawal in forum Installation and Deployment
    Replies: 10
    Last Post: 9th February 2007, 12:12
  4. execution of slots
    By smalls in forum Qt Programming
    Replies: 2
    Last Post: 22nd January 2006, 19:38

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.