Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. QWIDGET: CANNOT CREATE A QWIDGET WITHOUT QAPPLICATION - Message Box
Forum Updated to NodeBB v4.3 + New Features

QWIDGET: CANNOT CREATE A QWIDGET WITHOUT QAPPLICATION - Message Box

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
qt mobile
3 Posts 3 Posters 4.4k Views 1 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.
  • M Offline
    M Offline
    Mathan M
    wrote on 28 Jul 2016, 13:43 last edited by
    #1

    Hi,

    I used the Qmessage Box in the project created Qt Quick C++ template.
    When I try to show an message box, I encounter the following error:

    QWIDGET: CANNOT CREATE A QWIDGET WITHOUT QAPPLICATION

    Code:

    void QtCPPSearchVOne::funsearchMap()
    {
    QString obj;
    obj = QString::QString("Event Fired");

    QMessageBox msgbox;
    msgbox.setText(obj );
    msgbox.exec();
    }

    Thanks in advance.

    Mathan

    1 Reply Last reply
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 28 Jul 2016, 20:54 last edited by
      #2

      Hi,

      Go to your main.cpp You'll see there that a QGuiApplication is created. Replace it by QApplication.

      As to why: there's no need for widget support when writing a Qt Quick application unless you make use of classes like QMessageBox.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      J 1 Reply Last reply 13 May 2021, 01:26
      2
      • S SGaist
        28 Jul 2016, 20:54

        Hi,

        Go to your main.cpp You'll see there that a QGuiApplication is created. Replace it by QApplication.

        As to why: there's no need for widget support when writing a Qt Quick application unless you make use of classes like QMessageBox.

        J Offline
        J Offline
        JANG SOONMYUN
        wrote on 13 May 2021, 01:26 last edited by
        #3

        @SGaist said in QWIDGET: CANNOT CREATE A QWIDGET WITHOUT QAPPLICATION - Message Box:

        writing

        Thank you so much! I had a problem with opencv::imshow. And this solution works well.

        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