Ashot
Ashot

Reputation: 10959

Qt error: `qApp' was not declared in this scope

As I know qApp is global pointer so it should be accessible anywhere but I am getting this error error: qApp was not declared in this scope.

  1 #include "textEdit.h"
  2
  3 TextEdit::TextEdit() {
  4 }
  5
  6 void TextEdit::insertFromMimeData (const QMimeData * source) {
  7     if (qApp->mouseButtons() == Qt::MidButton) {
  8         return;
  9     }
 10     QTextEdit::insertFromMimeData(source);
 11 }
 12
 13

Upvotes: 10

Views: 14042

Answers (3)

Muckle_ewe
Muckle_ewe

Reputation: 1123

You need to use

#include <QApplication>

to use the qApp macro. See documentation at http://doc.qt.io/qt-5/qapplication.html#qApp

Upvotes: 18

RadhaKrishna
RadhaKrishna

Reputation: 312

qApp is declared in qapplication.h file. Include it.

Upvotes: 3

Johny
Johny

Reputation: 1997

You probably forgot to include header with the declaration.

 #include <QApplication>

Upvotes: 6

Related Questions