Results 1 to 11 of 11

Thread: QMessageBox ( Core Dumped )

  1. #1
    Join Date
    Sep 2006
    Posts
    42
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    2

    Default QMessageBox ( Core Dumped )

    Staff, the QMessageBox below functions normal. More when I pressed the Esc keyboard key, occurs Core dumped in the App.

    % Segmentation fault (core dumped)

    Qt Code:
    1. QMessageBox mb("App", "Hello Message ",
    2. QMessageBox::NoIcon,
    3. QMessageBox::Yes | QMessageBox::Default,
    4. QMessageBox::Cancel, QMessageBox::Escape );
    5.  
    6. mb.setButtonText( QMessageBox::Yes, "Ok" );
    7. mb.setButtonText( QMessageBox::Cancel, "Cancel" );
    8.  
    9. QPixmap exportSuccess( QPixmap::fromMimeSource( "message.png" ) );
    10. mb.setIconPixmap(exportSuccess);
    11.  
    12. mb.exec();
    To copy to clipboard, switch view to plain text mode 

    Cris
    Last edited by wysota; 28th January 2007 at 10:26. Reason: missing [code] tags

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

    Default Re: QMessageBox ( Core Dumped )

    Can we see the backtrace?

  3. #3
    Join Date
    Sep 2006
    Posts
    42
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    2

    Default Re: QMessageBox ( Core Dumped )

    Here it is the method.

    Qt Code:
    1. void AppForm::primeUpdateQuery()
    2. {
    3. QMessageBox mb("App",
    4. "!!! Here message !!!",
    5. QMessageBox::NoIcon,
    6. QMessageBox::Yes | QMessageBox::Default,
    7. QMessageBox::Cancel, QMessageBox::Escape );
    8.  
    9. mb.setButtonText( QMessageBox::Yes, "Ok" );
    10. mb.setButtonText( QMessageBox::Cancel, "Cancel" );
    11.  
    12. QPixmap exportSuccess( QPixmap::fromMimeSource( "message.png" ) );
    13. mb.setIconPixmap(exportSuccess);
    14.  
    15. /* It get the value of the QDataTable Current */
    16. QSqlRecord *getCurrentItemIdSql = new QSqlRecord();
    17. getCurrentItemIdSql = dataTable->currentRecord();
    18.  
    19. register int i = dataTable->currentRow();
    20. if ( i == -1 ) i = 0; /* Always use the first row */
    21.  
    22. else if ( getCurrentItemIdSql )
    23. {
    24. QSqlQuery queryUpdateSaida;
    25.  
    26. switch( mb.exec() )
    27. {
    28. case QMessageBox::Yes:
    29.  
    30. /* Now, it executes query for the exit of the occurrence */
    31. queryUpdateSaida.prepare( QUERY_EXIT_OCCURRENCE "id_ocorrencia= :id_ocorrencia AND id_viatura= :id_viatura "
    32. "AND id_cidade= :id_cidade ;" );
    33.  
    34. queryUpdateSaida.bindValue( ":id_ocorrencia", getCurrentItemIdSql->value("id_ocorrencia").toInt() );
    35. queryUpdateSaida.bindValue( ":id_viatura", getCurrentItemIdSql->value("id_viatura").toString() );
    36. queryUpdateSaida.bindValue( ":id_cidade", getCurrentItemIdSql->value("id_cidade").toInt() );
    37.  
    38. if ( queryUpdateSaida.exec() )
    39. {
    40. cout << "App ==> OK" << endl;
    41.  
    42. } else {
    43.  
    44. cout << "App ==> Error" << endl;
    45. }
    46.  
    47. dataTable->refresh(QDataTable::RefreshData);
    48. break;
    49.  
    50. case QMessageBox::Cancel:
    51.  
    52. dataTable->refresh(QDataTable::RefreshData);
    53. break;
    54.  
    55. default:
    56.  
    57. cout << "App ==> Case default" << endl;
    58.  
    59. }
    60.  
    61. return;
    62. }
    63. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by wysota; 28th January 2007 at 10:27. Reason: missing [code] tags

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

    Default Re: QMessageBox ( Core Dumped )

    Jacek wanted a backtrace (a list of functions called when the process crashed generated by a debugger), not the code.

  5. #5
    Join Date
    Sep 2006
    Posts
    42
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    2

    Default Re: QMessageBox ( Core Dumped )

    Ok, I am using option -g in qmake.

    % gdb ./app
    (gdb) run
    ....
    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x813e000 (LWP 100142)]
    0x2845623c in QButton::animateClick () from /usr/X11R6/lib/libqt-mt.so.3
    (gdb)

    This is the error when it is Esc keyboard.

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

    Default Re: QMessageBox ( Core Dumped )

    when in gdb use the "bt" command to print a backtrace.

  7. #7
    Join Date
    Sep 2006
    Posts
    42
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    2

    Default Re: QMessageBox ( Core Dumped )

    Ok,

    Program received signal SIGSEGV, Segmentation fault.
    [Switching to Thread 0x813e000 (LWP 100077)]
    0x2845623c in QButton::animateClick () from /usr/X11R6/lib/libqt-mt.so.3
    (gdb) bt
    #0 0x2845623c in QButton::animateClick () from /usr/X11R6/lib/libqt-mt.so.3
    #1 0x28561971 in QMessageBox::keyPressEvent () from /usr/X11R6/lib/libqt-mt.so.3
    #2 0x283fd31c in QWidget::event () from /usr/X11R6/lib/libqt-mt.so.3
    #3 0x2836e545 in QApplication::internalNotify () from /usr/X11R6/lib/libqt-mt.so.3
    #4 0x2836ed08 in QApplication::notify () from /usr/X11R6/lib/libqt-mt.so.3
    #5 0x28307b78 in QETWidget::translateKeyEvent () from /usr/X11R6/lib/libqt-mt.so.3
    #6 0x2830e37e in QApplication::x11ProcessEvent () from /usr/X11R6/lib/libqt-mt.so.3
    #7 0x283205ec in QEventLoop::processEvents () from /usr/X11R6/lib/libqt-mt.so.3
    #8 0x2838293b in QEventLoop::enterLoop () from /usr/X11R6/lib/libqt-mt.so.3
    #9 0x2836d8a8 in QApplication::enter_loop () from /usr/X11R6/lib/libqt-mt.so.3
    #10 0x285388c0 in QDialog::exec () from /usr/X11R6/lib/libqt-mt.so.3
    #11 0x0805f082 in compForm::primeUpdateSaida (this=0x8265200) at src/comp/compForm.cpp:647
    #12 0x080a3ab8 in compForm::qt_invoke (this=0x8265200, _id=74, _o=0xbfbfdf10) at src/comForm/moc_compForm.cpp:161
    #13 0x283ca6a4 in QObject::activate_signal () from /usr/X11R6/lib/libqt-mt.so.3
    #14 0x283cad15 in QObject::activate_signal () from /usr/X11R6/lib/libqt-mt.so.3
    #15 0x286d1a4c in QButton::clicked () from /usr/X11R6/lib/libqt-mt.so.3
    #16 0x2845695a in QButton::mouseReleaseEvent () from /usr/X11R6/lib/libqt-mt.so.3
    #17 0x283fd2b7 in QWidget::event () from /usr/X11R6/lib/libqt-mt.so.3
    #18 0x2836e545 in QApplication::internalNotify () from /usr/X11R6/lib/libqt-mt.so.3
    #19 0x2836e801 in QApplication::notify () from /usr/X11R6/lib/libqt-mt.so.3
    #20 0x2830ff1f in QETWidget::translateMouseEvent () from /usr/X11R6/lib/libqt-mt.so.3
    #21 0x2830ee9f in QApplication::x11ProcessEvent () from /usr/X11R6/lib/libqt-mt.so.3
    #22 0x283205ec in QEventLoop::processEvents () from /usr/X11R6/lib/libqt-mt.so.3
    #23 0x2838293b in QEventLoop::enterLoop () from /usr/X11R6/lib/libqt-mt.so.3
    #24 0x28382894 in QEventLoop::exec () from /usr/X11R6/lib/libqt-mt.so.3
    #25 0x2836d880 in QApplication::exec () from /usr/X11R6/lib/libqt-mt.so.3
    #26 0x08058165 in main (argc=1, argv=0xbfbfe9fc) at src/main.cpp:286
    (gdb)
    Last edited by wysota; 28th January 2007 at 18:17. Reason: Disabled smilies

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

    Default Re: QMessageBox ( Core Dumped )

    In my opinion you should either call
    Qt Code:
    1. mb.setButtonText( QMessageBox::Escape, "Text for 'escape' button" );
    To copy to clipboard, switch view to plain text mode 
    or make Cancel and Escape the same button (by substituting the comma with a pipe "|"). I doubt Escape should be used as a button number, are you sure you want that?

  9. #9
    Join Date
    Sep 2006
    Posts
    42
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11
    Thanks
    2

    Default Re: QMessageBox ( Core Dumped )

    If it will be added “|” occurs error in the compilation.

    QMessageBox::Cancel | QMessageBox::Escape


    src/comp/compForm.cpp::540: error: no matching function for call to `QMessageBox::QMessageBox(const char[21], const QString, QMessageBox::Icon, int, int)'
    /usr/X11R6/include/qmessagebox.h:192: note: candidates are: QMessageBox::QMessageBox(const QMessageBox&)
    /usr/X11R6/include/qmessagebox.h:68: note: QMessageBox::QMessageBox(const QString&, const QString&, QMessageBox::Icon, int, int, int, QWidget*, const char*, bool, uint)
    /usr/X11R6/include/qmessagebox.h:64: note: QMessageBox::QMessageBox(QWidget*, const char*)
    *** Error code 1

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

    Default Re: QMessageBox ( Core Dumped )

    Pass QMessageBox::NoButton as the third int argument.

  11. #11
    Join Date
    Sep 2006
    Location
    Rio de Janeiro, Brazil
    Posts
    44
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Thanks
    2
    Thanked 3 Times in 3 Posts

    Default Re: QMessageBox ( Core Dumped )

    It makes thus.

    ...
    QMessageBox::NoIcon, QMessageBox::Yes | QMessageBox:efault,
    QMessageBox::Cancel | QMessageBox::Escape, QMessageBox::NoButton );

Similar Threads

  1. QLineEdit Segmentation fault (core dumped)
    By cristiano in forum Qt Programming
    Replies: 1
    Last Post: 12th October 2006, 06:18
  2. customize the Icon QMessageBox
    By QiT in forum Newbie
    Replies: 1
    Last Post: 26th August 2006, 11:40
  3. Problem of Core Dropped!
    By Stephano in forum General Programming
    Replies: 1
    Last Post: 10th May 2006, 16:59

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
  •  
Qt is a trademark of The Qt Company.