Results 1 to 4 of 4

Thread: Presenting error messages in one window.

  1. #1
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Presenting error messages in one window.

    Good day,
    I need to create a non-modal dialog on which I can present error messages as they are received. The idea is to open a new window if I get an error and to add lines to the detailed description if any new error is reported while the dialog is still open.
    I subclassed the QMessageBox to make it singleton and then the code that calls the window is something like this
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. errWind = ErrorWindow::Instance();
    4. errWind->setModal(false);
    5. errWind->setText("Errores:");
    6. QString msg = errWind->detailedText();
    7. msg.append("ERROR\n");
    8. errWind->setDetailedText(msg);
    9. errWind->show();
    10. // int ret = errWind->exec();
    11. // if(ret==QMessageBox::Ok)
    12. // errWind->setDetailedText("");
    13. }
    To copy to clipboard, switch view to plain text mode 
    The commented code is there because I wan to clean the detailedText when the ok button is pushed, but the exec() makes the window modal and that does not work for me.
    How can I clear the detailed text on Ok button pushed?
    I already tried overloading the done() and the accepted() functions, but that does not worked for me.
    Thanks in advance for any idea

  2. #2
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Presenting error messages in one window.

    What about QMessageBox::clickedButton () ?

  3. #3
    Join Date
    Mar 2011
    Posts
    23
    Thanks
    6
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Presenting error messages in one window.

    Hmmm i fail to see how to use that function. I see the example, but i'm not sure about how to apply it


    Added after 7 minutes:


    Ok, this is what i have done and it seems to work. Can you see any problem with this method?
    Qt Code:
    1. void MainWindow::on_pushButton_clicked()
    2. {
    3. errWind = ErrorWindow::Instance();
    4. errWind->setModal(false);
    5. errWind->setText("Errores:");
    6. QString msg = errWind->detailedText();
    7. msg.append("ERROR\n");
    8. errWind->setDetailedText(msg);
    9. errWind->show();
    10. connect(errWind,SIGNAL(buttonClicked(QAbstractButton*)),this,SLOT(clearErrors(QAbstractButton*)));
    11. }
    12.  
    13. void MainWindow::clearErrors(QAbstractButton*)
    14. {
    15. errWind->setDetailedText("");
    16. }
    To copy to clipboard, switch view to plain text mode 

    Thanks
    Last edited by AndresBarbaRoja; 17th June 2011 at 16:05.

  4. #4
    Join Date
    Jun 2011
    Location
    Finland
    Posts
    164
    Thanks
    1
    Thanked 26 Times in 26 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Maemo/MeeGo

    Default Re: Presenting error messages in one window.

    Yes it is perfectly fine if you have only 1 button. If you have 2 buttons, then use ButtonRole QMessageBox::buttonRole ( QAbstractButton * button ) const to check what button has been presssed

Similar Threads

  1. QtWebkit and JavaScript error messages
    By Diph in forum Qt Programming
    Replies: 1
    Last Post: 29th April 2009, 11:10
  2. X window error
    By lostson in forum Installation and Deployment
    Replies: 0
    Last Post: 4th October 2008, 19:50
  3. Replies: 5
    Last Post: 17th July 2008, 13:12
  4. Finding window, linker error
    By Khal Drogo in forum Qt Programming
    Replies: 7
    Last Post: 14th March 2008, 12:49

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.