Results 1 to 13 of 13

Thread: QSLQuery and progress messages

  1. #1
    Join Date
    Apr 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QSLQuery and progress messages

    Hello I need to capture the progress messages generated when I execute the query ANALYZE VERBOSE, actually the messages are printed in the qDebug, What I need is to show those messages in a text box of my app.

    This is my query:

    QSqlQuery query(bd_seleccionada);
    query.exec("ANALYZE VERBOSE;");


    Help PLEASE!!!!
    Last edited by dcypher; 1st April 2013 at 20:47. Reason: updated contents

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSLQuery and progress messages

    A progress of what? exec() returns only the final output of the query you send to the server.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    Apr 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSLQuery and progress messages

    when I execute the query, it shows me a lot of messages in the qDebug, like these:
    INFO: analyzing "pg_catalog.pg_type"
    INFO: "pg_type": scanned 7 of 7 pages, containing 315 live rows and 0 dead rows; 315 rows in sample, 315 estimated total rows
    INFO: analyzing "pg_catalog.pg_attribute"
    INFO: "pg_attribute": scanned 38 of 38 pages, containing 2181 live rows and 0 dead rows; 2181 rows in sample, 2181 estimated total rows
    INFO: analyzing "pg_catalog.pg_authid"
    INFO: "pg_authid": scanned 1 of 1 pages, containing 11 live rows and 0 dead rows; 11 rows in sample, 11 estimated total rows
    INFO: analyzing "pg_catalog.pg_class"
    INFO: "pg_class": scanned 7 of 7 pages, containing 284 live rows and 1 dead rows; 284 rows in sample, 284 estimated total rows
    .......
    I need to capture thoses messages and put them in a text box.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSLQuery and progress messages

    QSqlQuery will not help you with that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Apr 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSLQuery and progress messages

    any idea of how to capture those messages?? Is there a way to capture the text printed by qDebug??

  6. #6
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSLQuery and progress messages

    The messages are output by the PostgreSql directly to one of your processes standard streams, i.e. not from Qt and not via QDebug. If you cannot use a simple command line redirection, e.g. "run_my_program 2>error.txt", then you would need to redirect the std::cerr (maybe std::cout) streams of your program to a string buffer or file. Plenty of guidance on how to do that on the 'net e.g. http://stackoverflow.com/questions/5...rr-to-a-string

    If you only want the results then they are left in a PostgreSQL system table.

  7. #7
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,536
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QSLQuery and progress messages

    Quote Originally Posted by dcypher View Post
    any idea of how to capture those messages?? Is there a way to capture the text printed by qDebug??
    Yes, read about qInstallMsgHandler

  8. #8
    Join Date
    Apr 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSLQuery and progress messages

    Quote Originally Posted by ChrisW67 View Post
    The messages are output by the PostgreSql directly to one of your processes standard streams, i.e. not from Qt and not via QDebug. If you cannot use a simple command line redirection, e.g. "run_my_program 2>error.txt", then you would need to redirect the std::cerr (maybe std::cout) streams of your program to a string buffer or file. Plenty of guidance on how to do that on the 'net e.g. http://stackoverflow.com/questions/5...rr-to-a-string

    If you only want the results then they are left in a PostgreSQL system table.
    I try this but it still does not capture any message, and the messages are still printed by the qDebug. This is my code, please help meeee!!!:

    std::stringstream buffer;
    std::streambuf * old = std::cerr.rdbuf(buffer.rdbuf());
    //these messages are what i want to capture
    consulta->Analyze();//here i do query.exec("ANALYZE VERBOSE")
    //this is captured ok
    std::cerr << "Error";//this works
    std::string text = buffer.str();

    QString msg = QString::fromStdString(text);

  9. #9
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QSLQuery and progress messages

    As risk of sounding like a broken record:
    The messages are output by the PostgreSql directly ... , i.e. not from Qt and not via QDebug.
    Did you try redirecting std::cout? Have you asked the PostgreSQL people how you might do this?

  10. #10
    Join Date
    Apr 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSLQuery and progress messages

    yes I 've tryed with std::cout and still no messages, i almost give up, may be there's no way doing this. What makes me anger is that I can see the messages printed by the qDebug console BRRR!!!!

  11. #11
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSLQuery and progress messages

    Those messages are not printed by "qDebug console". They are printed by libpq.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  12. #12
    Join Date
    Apr 2013
    Posts
    7
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QSLQuery and progress messages

    any idea of how to capture them?? please an example will be very usefull, i'm just begining in c++ and my english is very poor.

  13. #13
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QSLQuery and progress messages

    Ask at some PostgreSQL forum, this has nothing to do with Qt.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


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.