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. Error Message box without using QGuiApplication

Error Message box without using QGuiApplication

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 4 Posters 883 Views 3 Watching
  • 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.
  • A Offline
    A Offline
    abhishekm
    wrote on last edited by abhishekm
    #1

    I am building a cross platform application using Qt Quick/qml. I would like to show an error message box without using QGuiApplication or QApplication. There can be situations where I do not have a QApplication instantiated or in any situation, it is not getting instantiated. Hence, in such cases, if any exception occurs, would like to show a message box to the user.

    Using the qMessageHandler, I can capture the signal from OS. But how can this error be shown as a message/error window for all platform ?

    Is there any way a message box can be shown without using QApplication for windows, macOS, android and ios ?

    jsulmJ 1 Reply Last reply
    0
    • A abhishekm

      I am building a cross platform application using Qt Quick/qml. I would like to show an error message box without using QGuiApplication or QApplication. There can be situations where I do not have a QApplication instantiated or in any situation, it is not getting instantiated. Hence, in such cases, if any exception occurs, would like to show a message box to the user.

      Using the qMessageHandler, I can capture the signal from OS. But how can this error be shown as a message/error window for all platform ?

      Is there any way a message box can be shown without using QApplication for windows, macOS, android and ios ?

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @abhishekm said in Error Message box without using QGuiApplication:

      There can be situations where I do not have a QApplication initialized or in any situation, it is not getting initialized

      What would be such a situation? I mean, QApplication is usually the first thing instantiated in a Qt application. "it is not getting initialized" - in such a situation you should not expect to be able to show any UI reliably as your application is in an undefined state.
      What is your use case?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      A 1 Reply Last reply
      1
      • jsulmJ jsulm

        @abhishekm said in Error Message box without using QGuiApplication:

        There can be situations where I do not have a QApplication initialized or in any situation, it is not getting initialized

        What would be such a situation? I mean, QApplication is usually the first thing instantiated in a Qt application. "it is not getting initialized" - in such a situation you should not expect to be able to show any UI reliably as your application is in an undefined state.
        What is your use case?

        A Offline
        A Offline
        abhishekm
        wrote on last edited by
        #3

        @jsulm As you mentioned, because the application is in an undefined state, would like to show a message to the user; lets say - user needs to reinstall the application due to some error/configuration; or the system is out of memory; My application also does a bunch of internal things before QApplication is instantiated. If I still want to show a message to the user, how would the same be achieved ? Does this help in the use case ?

        Pablo J. RoginaP JonBJ 2 Replies Last reply
        0
        • A abhishekm

          @jsulm As you mentioned, because the application is in an undefined state, would like to show a message to the user; lets say - user needs to reinstall the application due to some error/configuration; or the system is out of memory; My application also does a bunch of internal things before QApplication is instantiated. If I still want to show a message to the user, how would the same be achieved ? Does this help in the use case ?

          Pablo J. RoginaP Offline
          Pablo J. RoginaP Offline
          Pablo J. Rogina
          wrote on last edited by
          #4

          @abhishekm said in Error Message box without using QGuiApplication:

          My application also does a bunch of internal things before QApplication is instantiated

          Why not reverse the order? I mean, initialize QApplication as soon as possible, then do the bunch of internal things

          Upvote the answer(s) that helped you solve the issue
          Use "Topic Tools" button to mark your post as Solved
          Add screenshots via postimage.org
          Don't ask support requests via chat/PM. Please use the forum so others can benefit from the solution in the future

          1 Reply Last reply
          1
          • A abhishekm

            @jsulm As you mentioned, because the application is in an undefined state, would like to show a message to the user; lets say - user needs to reinstall the application due to some error/configuration; or the system is out of memory; My application also does a bunch of internal things before QApplication is instantiated. If I still want to show a message to the user, how would the same be achieved ? Does this help in the use case ?

            JonBJ Online
            JonBJ Online
            JonB
            wrote on last edited by
            #5

            @abhishekm said in Error Message box without using QGuiApplication:

            My application also does a bunch of internal things before QApplication is instantiated. If I still want to show a message to the user, how would the same be achieved ? Does this help in the use case ?

            I do not believe that is possible. You need at least a QGuiApplication

            Since the QGuiApplication object does so much initialization, it must be created before any other objects related to the user interface are created.

            To use Qt's cross-platform abstraction even for displaying a QMessageBox, you need that, in fact you need a QApplication which inherits from QGuiApplication. I can't think of anything Qt you can use to display a message box without that. Unless you want to write your own native calls.

            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