Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QMessageBox in MFC application
Forum Update on Monday, May 27th 2025

QMessageBox in MFC application

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RogerCui
    wrote on last edited by
    #1

    Hi Experts,

    I have a MFC MDI application, and somewhere I'd like to pop up a QMessageBox.
    However, I find that the message box is not modal, I still can interact with "view" and "main frame" in MFC world.
    Here're my codes, any suggestions? Thanks!

    @
    // parentHwnd is the HWND of CView from MFC
    m_parent = new QWinWidget(parentHwnd);
    QMessageBox msg(m_parent);
    msg.exec();
    @

    Thanks
    Roger

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vcsala
      wrote on last edited by
      #2

      As I know if parent is not null the message box will be window modal relative to the parent. But it still not solves (if I understand well the comment in the first line) why you can interact with the view.

      1 Reply Last reply
      0
      • G Offline
        G Offline
        giesbert
        wrote on last edited by
        #3

        Exec spinns a local event loop.But I'm not sure, whether this loop catches th windows event or sends them to the corresponding windows...

        Nokia Certified Qt Specialist.
        Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

        1 Reply Last reply
        0
        • R Offline
          R Offline
          RogerCui
          wrote on last edited by
          #4

          Thanks All, I find the cause: I should set parent window to main frame(instead of the view)

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved