'class QCoreApplication' has no member named 'setStyleSheet'
I simply want to use a style sheet.
I get this error when I want to Compile
Quote:
C:\Erfan\C++\Exersize\QT\untitled01\main.cpp:19: error: 'class QCoreApplication' has no member named 'setStyleSheet'
QApplication::instance()->setStyleSheet(ts.readAll());
^
Here's my Code
Code:
#include "mainwindow.h"
#include <QApplication>
#include <QFile>
#include <Qtextstream>
int main(int argc, char *argv[])
{
QFile f
(":qdarkstyle/style.qss");
if (!f.exists())
{
printf("Unable to set stylesheet, file not found\n");
}
else
{
}
MainWindow w;
w.show();
return a.exec();
}
Re: 'class QCoreApplication' has no member named 'setStyleSheet'
Try shifting QApplication a(argc, argv) a bit up and use rather a.setStyleSheet() than QApplication::instance().
(1) When you call QApplication::instance() there is no QApplication instance around.
(2) QApplication::instance() is an inherited method that returns QCoreApplication * Even if the program compiled, the returned pointer would be NULL.
(3) If you want QApplication::instance() anyway use dynamic_cast.