-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
41 lines (36 loc) · 1.35 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <QApplication>
#include <QGuiApplication> //?
#include <QDebug>
#include <QCommandLineParser>
#include <QCoreApplication>
#include <QLoggingCategory>
#include "mainwindow.h"
//--------------------------------------------------------
// Declare database connection outside of any function. It
// also needs "include QCoreApplication" environment.
QSqlDatabase MainWindow::g_db;
//--------------------------------------------------------
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
//--- Read commandline options.
bool verbose = false; // Defaults to no qDebug output.
QCoreApplication::setApplicationName("ChemCalc");
QCommandLineParser parser;
parser.setApplicationDescription("A Chemical Calculator");
parser.addHelpOption();
QCommandLineOption verboseOption(QStringList() << "v" << "verbose", "Verbose debugging output");
parser.addOption(verboseOption);
// Process the actual command line arguments given by the user
parser.process(app);
verbose = parser.isSet(verboseOption);
if (!verbose){
// This turns off qDebug messages in all chemcalc code.
// Comment out next line (and revert when done) for IDE debugging.
QLoggingCategory::setFilterRules("*.debug=false"); //<-- UNCOMMENT <<--<<--
};
//----
MainWindow w;
w.show();
return app.exec();
}