Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8999289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:09:38+00:00 2026-06-16T00:09:38+00:00

I am developing Qt application (Qt version 4.7.3) on SBC6000x board. I have a

  • 0

I am developing Qt application (Qt version 4.7.3) on SBC6000x board.

I have a MessageBox class derived from QDialog. I have made this class singleton.

Whenever a messagebox is to be show I am using .exec method to show it.

There are few places where I need to show messageboxes one after another.

So, to show new messagebox, I have to close previous one and show new one.

e.g. When Messagebox is open and at same time I receive an error from background I have to close the messagebox which is currently shown and show the one with error.

To closes previous dialog I have exposed CloseDlg method from messagebox class and trying to close it.

Inside this CloseDlg I am emitting finished signal.

void CMsgBox::CloseDlg()
{
    if (NULL != CMsgBox::m_msgBox)
    {
        if(CMsgBox::m_msgBox->isVisible())
        {
            emit CMsgBox::m_msgBox->finished(0);
            //QApplication::processEvents();
        }
    }
}

and calling it as

CMsgBox::CloseDlg();

My show method is :-

int CMsgBox::showMsgBox(Icon icon, const QString &textMsg, const QString &okBtnText)
{
    if (CMsgBox::m_msgBox == NULL)
    {
        CMsgBox::m_msgBox = new CMsgBox();
    }
    CMsgBox::m_msgBox->setText(textMsg);
    CMsgBox::m_msgBox->setIcon(icon);
    CMsgBox::m_msgBox->setOkBtnText(okBtnText);
    CMsgBox::m_msgBox->exec();

    return CMsgBox::m_msgBox->m_btnPressed; //return, unblock the call
}

Again when I call showMsgBox,it is showing me following warning.
QDialog::exec: Recursive call detected

Problem is, it doesn’t return from previous exec call (unless we return, as commented above //).

I tried same with close(), accept(), reject() methods instead of finished() event but nothing worked.

What is the way to return from previous exe call and achieve above scenario? Any help is welcome.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T00:09:39+00:00Added an answer on June 16, 2026 at 12:09 am

    What you have here looks like a race condition. A modal QDialog runs its own event loop, so your application behaves like a multithreaded application and you need to take care of concurrency and race conditions.

    When you receive a second in your main event loop, you call CMsgBox::CloseDlg() and CMsgBox::showMsgBox() in quick succession. However, CloseDlg() tells the dialog’s event loop to return, but CloseDlg() actually returns before the dialog’s event loop is done cleaning up, and showMsgBox() attempts to call exec() on a dialog which hasn’t finished exiting yet.

    What you need to do is, when you call CMsgBox::CloseDlg(), connect to the finished(int) signal, and only when you receive the finished(int) can you safely exec() the dialog again.

    NOTE: When connecting to the finished(int) signal, make sure to use a Qt::QueuedConnection instead of a Qt::DirectConnection which is the default.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Currently developing an application using the newest version of symfony, obtained through PEAR. This
I am developing an application via the Google Maps API (Version 3). I have
I'm developing a JSF web application, with the current 2.1.7 JSF version . Actually,
I'm developing application using backbone.js & jquery. I have following code in model: runReport:
while developing an application how to get current operating system version installed in mobile
I am developing an application in SQL Server using C#. My database version is
I have been developing an application in VS2010 and compiling it for the .NET
I am developing an application that is on version 3.2 which consists of a
I'm developing android application using eclipse and svn for version control. I wanted to
I am developing an application similar to email application.Whenever new message is received my

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.