Nominate our 2022 Qt Champions!

Exception after QMessageBox opened from C++ when another full-screen QDialog opened (android)

  • Scenario: There's a full-screen custom QDialog in place, now the dialog sends a Signal to back-end causing the back-end to open-up a QMessageBox (sort of a typical situation I would say).

    Now, things go wrong with no debug-able errors from runtime environment

    W QObject::setParent: Cannot set parent, new parent is in a different thread
    E DecorView: mWindow.mActivityCurrentConfig is null


    void CTools::showNotification(QString title, QString msg, eNotificationType::eNotificationType eType)
        QMessageBox msgBox;
        case eNotificationType::success:
        case eNotificationType::warning:
        case eNotificationType::notification:

    Then the QMessageBox does open (without the instructed icon) followed by a sequence of segmentation faults. Of course we haven't spawned any thread at all besides the main one. Ideas?

  • Lifetime Qt Champion

    @Vega4 said in Exception after QMessageBox opened from C++ when another full-screen QDialog opened (android):;

    Your msgBox is a local variable and show() is a non blocking call, so msgBox will disappear just after
    Either allocate the dialog on the heap or use exec().

  • This post is deleted!

  • @jsulm I got to know that in fact it was not setParent(0) that fixed the issue but usage of .exec() indeed. Now that makes 100% sense, QMessageBox allocated on stack, it got deleted. Now I got into conclusions too soon on that one. It works. The icon is not set but we'll live with that for now.

Log in to reply