#include #include #include #include #include "mainwindow.h" static void initStyleSheet(QApplication& a) { QFile f(":ads/stylesheets/default-windows2.css"); if (f.open(QFile::ReadOnly)) { const QByteArray ba = f.readAll(); f.close(); a.setStyleSheet(QString(ba)); } } void myMessageOutput(QtMsgType type, const QMessageLogContext &context, const QString &msg) { QByteArray localMsg = msg.toLocal8Bit(); switch (type) { case QtDebugMsg: fprintf(stdout, "Debug: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; case QtInfoMsg: fprintf(stdout, "Info: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; case QtWarningMsg: fprintf(stderr, "Warning: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; case QtCriticalMsg: fprintf(stderr, "Critical: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); break; case QtFatalMsg: fprintf(stderr, "Fatal: %s (%s:%u, %s)\n", localMsg.constData(), context.file, context.line, context.function); abort(); } fflush(stderr); fflush(stdout); } int main(int argc, char *argv[]) { QApplication a(argc, argv); a.setQuitOnLastWindowClosed(true); initStyleSheet(a); qInstallMessageHandler(myMessageOutput); qDebug() << "Message handler test"; MainWindow mw; mw.show(); return a.exec(); }