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

As I know, qApp is a global pointer, so it should be accessible anywhere, but I get 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 
+4
source share
3 answers

You need to use

 #include <QApplication> 

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

+10
source

You probably forgot to include an ad headline.

  #include <QApplication> 
+3
source

qApp declared in the qapplication.h file. Turn it on.

+1
source

Source: https://habr.com/ru/post/1492996/


All Articles