Results 1 to 3 of 3

Thread: Showing QDialog in eventFilter()

  1. #1
    Join Date
    Aug 2008
    Posts
    132
    Thanks
    23
    Thanked 3 Times in 3 Posts

    Default Showing QDialog in eventFilter()

    Hi

    I'm wondering if it is a good idea to show a QDialog() in an event filter. I've recently been seeing crashes as soon as I call exec() on a dialog. I show the dialog by simply calling exec() on it. The code below is called as the result of a drop operation on a QTreeView which I catch in the event filter:

    Qt Code:
    1. if (d->name_dialog->exec()) { // Crashes here (line 58 in the stack trace below)
    2. if (d->name_dialog->selectedResolution() == Reject)
    3. return_value = false;
    4. else
    5. return_value = true;
    To copy to clipboard, switch view to plain text mode 

    Is this a basic mistake? If so what is the correct way to show a dialog in a event filter?

    Thanks,
    Jaco

    Qt Code:
    1. 0 qt_blend_argb32_on_argb32_sse2 emmintrin.h 1239 0x5931e8
    2. 1 QRasterPaintEnginePrivate::drawImage qpaintengine_raster.cpp 1067 0x73117f
    3. 2 QRasterPaintEngine::drawImage qpaintengine_raster.cpp 2761 0x739db9
    4. 3 QRasterPaintEngine::drawPixmap qpaintengine_raster.cpp 2419 0x737a8c
    5. 4 QPainter::drawPixmap qpainter.cpp 5387 0x6c9051
    6. 5 QPainter::drawPixmap qpainter.h 847 0xd09223
    7. 6 QPixmapIconEngine::paint qicon.cpp 146 0x62bb61
    8. 7 QIcon::paint qicon.cpp 722 0x62e1dc
    9. 8 QCommonStyle::drawControl qcommonstyle.cpp 2194 0x8406b3
    10. 9 QWindowsStyle::drawControl qwindowsstyle.cpp 2560 0x90c907
    11. 10 QStyleSheetStyle::drawControl qstylesheetstyle.cpp 3979 0x8766a6
    12. 11 QStyledItemDelegate::paint qstyleditemdelegate.cpp 424 0xb1326f
    13. 12 QListView::paintEvent qlistview.cpp 1044 0xa9ef69
    14. 13 QWidget::event qwidget.cpp 8333 0x5f492d
    15. 14 QFrame::event qframe.cpp 557 0x96e6bc
    16. 15 QAbstractScrollArea::viewportEvent qabstractscrollarea.cpp 1043 0x9fbf0f
    17. 16 QAbstractItemView::viewportEvent qabstractitemview.cpp 1619 0xa85785
    18. 17 QAbstractScrollAreaPrivate::viewportEvent qabstractscrollarea_p.h 100 0xc56a13
    19. 18 QAbstractScrollAreaFilter::eventFilter qabstractscrollarea_p.h 116 0xc5506c
    20. 19 QCoreApplicationPrivate::sendThroughObjectEventFilters qcoreapplication.cpp 847 0x6a1ffc73
    21. 20 QApplicationPrivate::notify_helper qapplication.cpp 4392 0x5a96e5
    22. 21 QApplication::notify qapplication.cpp 4361 0x5a9586
    23. 22 QCoreApplication::notifyInternal qcoreapplication.cpp 732 0x6a1ff9dc
    24. 23 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 218 0xc1d53e
    25. 24 QWidgetPrivate::drawWidget qwidget.cpp 5420 0x5ed460
    26. 25 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5627 0x5ee176
    27. 26 QWidgetPrivate::drawWidget qwidget.cpp 5473 0x5ed8ab
    28. 27 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5627 0x5ee176
    29. 28 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5614 0x5ee036
    30. 29 QWidgetPrivate::drawWidget qwidget.cpp 5473 0x5ed8ab
    31. 30 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5627 0x5ee176
    32. 31 QWidgetPrivate::paintSiblingsRecursive qwidget.cpp 5614 0x5ee036
    33. 32 QWidgetPrivate::drawWidget qwidget.cpp 5473 0x5ed8ab
    34. 33 QWidgetBackingStore::sync qbackingstore.cpp 1320 0x774a5d
    35. 34 QWidgetPrivate::syncBackingStore qwidget.cpp 1805 0x5e4f50
    36. 35 QWidget::event qwidget.cpp 8480 0x5f4e75
    37. 36 QMainWindow::event qmainwindow.cpp 1417 0x98d23a
    38. 37 QApplicationPrivate::notify_helper qapplication.cpp 4396 0x5a9706
    39. 38 QApplication::notify qapplication.cpp 4361 0x5a9586
    40. 39 QCoreApplication::notifyInternal qcoreapplication.cpp 732 0x6a1ff9dc
    41. 40 QCoreApplication::sendEvent qcoreapplication.h 215 0xc1d592
    42. 41 sendUpdateRequest qbackingstore.cpp 507 0x771578
    43. 42 QWidgetBackingStore::markDirty qbackingstore.cpp 683 0x7721ba
    44. 43 QWidget::repaint qwidget.cpp 10237 0x5f778d
    45. 44 QWidget::repaint qwidget.cpp 10193 0x5f75b3
    46. 45 setDisabledStyle qwidget.cpp 8106 0xbd8a3e
    47. 46 QWidget::event qwidget.cpp 8502 0x5f4f6d
    48. 47 QMainWindow::event qmainwindow.cpp 1417 0x98d23a
    49. 48 QApplicationPrivate::notify_helper qapplication.cpp 4396 0x5a9706
    50. 49 QApplication::notify qapplication.cpp 4361 0x5a9586
    51. 50 QCoreApplication::notifyInternal qcoreapplication.cpp 732 0x6a1ff9dc
    52. 51 QCoreApplication::sendEvent qcoreapplication.h 215 0xc1d592
    53. 52 QApplicationPrivate::enterModal qapplication.cpp 2906 0x5a5a45
    54. 53 QWidgetPrivate::show_helper qwidget.cpp 7372 0x5f271b
    55. 54 QWidget::setVisible qwidget.cpp 7589 0x5f2f2d
    56. 55 QDialog::setVisible qdialog.cpp 739 0xa37528
    57. 56 QWidget::show qwidget.h 487 0xd08378
    58. 57 QDialog::exec qdialog.cpp 543 0xa36bbf
    59. 58 Qtilities::CoreGui::NamingPolicyFilter::validateNamePropertyChange NamingPolicyFilter.cpp 679 0x9374d93
    60. 59 Qtilities::CoreGui::NamingPolicyFilter::initializeAttachment NamingPolicyFilter.cpp 282 0x93703e3
    61. 60 Qtilities::Core::Observer::attachSubject Observer.cpp 866 0x6d0d7df5
    62. 61 FirmwareCore::Design::addDesignFile Design.cpp 493 0x6fcd69e8
    63. 62 FirmwareCore::DesignManager::addFileToDesign DesignManager.cpp 711 0x6fcd0481
    64. 63 FirmwareCore::DesignWidget::eventFilter DesignWidget.cpp 352 0x6fce8980
    65. 64 QCoreApplicationPrivate::sendThroughObjectEventFilters qcoreapplication.cpp 847 0x6a1ffc73
    66. 65 QApplicationPrivate::notify_helper qapplication.cpp 4392 0x5a96e5
    67. 66 QApplication::notify qapplication.cpp 4202 0x5a89ed
    68. 67 QCoreApplication::notifyInternal qcoreapplication.cpp 732 0x6a1ff9dc
    69. 68 QCoreApplication::sendEvent qcoreapplication.h 215 0xc1d592
    70. 69 QOleDropTarget::Drop qdnd_win.cpp 819 0x617326
    71. 70 ole32!StgGetIFillLockBytesOnFile C:\WINDOWS\system32\ole32.dll 0 0x775f8ec6
    72. 71 ole32!StgGetIFillLockBytesOnFile C:\WINDOWS\system32\ole32.dll 0 0x775f9108
    73. 72 ole32!CreateErrorInfo C:\WINDOWS\system32\ole32.dll 0 0x775cfce8
    74. 73 ole32!CreateErrorInfo C:\WINDOWS\system32\ole32.dll 0 0x775cfb70
    75. 74 QDragManager::drag qdnd_win.cpp 942 0x617851
    76. 75 QDrag::exec qdrag.cpp 284 0x5b2b90
    77. 76 QAbstractItemView::startDrag qabstractitemview.cpp 3437 0xa8d56a
    78. 77 QAbstractItemView::mouseMoveEvent qabstractitemview.cpp 1700 0xa85f7f
    79. 78 QTreeView::mouseMoveEvent qtreeview.cpp 1902 0xabcc04
    80. 79 QWidget::event qwidget.cpp 8172 0x5f4164
    81. 80 QFrame::event qframe.cpp 557 0x96e6bc
    82. 81 QAbstractScrollArea::viewportEvent qabstractscrollarea.cpp 1043 0x9fbf0f
    83. 82 QAbstractItemView::viewportEvent qabstractitemview.cpp 1619 0xa85785
    84. 83 QTreeView::viewportEvent qtreeview.cpp 1256 0xab9aa3
    85. 84 QAbstractScrollAreaPrivate::viewportEvent qabstractscrollarea_p.h 100 0xc56a13
    86. 85 QAbstractScrollAreaFilter::eventFilter qabstractscrollarea_p.h 116 0xc5506c
    87. 86 QCoreApplicationPrivate::sendThroughObjectEventFilters qcoreapplication.cpp 847 0x6a1ffc73
    88. 87 QApplicationPrivate::notify_helper qapplication.cpp 4392 0x5a96e5
    89. 88 QApplication::notify qapplication.cpp 3959 0x5a7909
    90. 89 QCoreApplication::notifyInternal qcoreapplication.cpp 732 0x6a1ff9dc
    91. 90 QCoreApplication::sendSpontaneousEvent qcoreapplication.h 218 0xc1d53e
    92. 91 QApplicationPrivate::sendMouseEvent qapplication.cpp 3056 0x5a6118
    93. 92 QETWidget::translateMouseEvent qapplication_win.cpp 3317 0x60fc63
    94. 93 QtWndProc@16 qapplication_win.cpp 1657 0x60aaa6
    95. 94 USER32!GetDC C:\WINDOWS\system32\user32.dll 0 0x7e418734
    96. 95 ?? 0 0x26091e
    97. 96 ?? 0 0x200
    98. 97 USER32!GetDC C:\WINDOWS\system32\user32.dll 0 0x7e418816
    99. 98 qt_is_translatable_mouse_event qapplication_win.cpp 1426 0x609fa5
    100. 99 USER32!GetWindowLongW C:\WINDOWS\system32\user32.dll 0 0x7e4189cd
    101. 100 ?? 0
    To copy to clipboard, switch view to plain text mode 

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

    Default Re: Showing QDialog in eventFilter()

    Yes, I think that's something you shouldn't do. I don't know what you are doing but probably you can do it outside an event filter.
    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
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Thanked 69 Times in 67 Posts

    Default Re: Showing QDialog in eventFilter()

    If you really think you have to, you should call open() on the dialog, not exec(). exec() starts another event loop leading to all kinds of unpredictable behavior.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  4. The following user says thank you to franz for this useful post:

    JPNaude (30th November 2010)

Similar Threads

  1. Replies: 4
    Last Post: 4th January 2009, 01:14
  2. QDialog not showing close button on Mac
    By manojmka in forum Qt Programming
    Replies: 2
    Last Post: 17th September 2008, 12:56
  3. Showing the QDialog in the task bar
    By Nyphel in forum Newbie
    Replies: 6
    Last Post: 17th April 2007, 10:25
  4. showing close Button(x) in QDialog
    By vishal.chauhan in forum Newbie
    Replies: 6
    Last Post: 4th April 2007, 10:01
  5. Showing QMainWindow without showing a child QWidget
    By discostu in forum Qt Programming
    Replies: 3
    Last Post: 4th March 2007, 09:03

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.