📄 main.cpp
字号:
#include <QString>#include <QDebug>#include <argumentlist.h> // in our utils libvoid processFile(QString filename, bool verbose) { if (verbose) qDebug() << QString("Do something chatty with %1.").arg(filename); else qDebug() << filename;}void runTestOnly(QStringList & listOfFiles, bool verbose) { foreach (QString current, listOfFiles) { /* Qt improved foreach loop */ processFile(current, verbose); }}int main( int argc, char * argv[] ) { ArgumentList al(argc, argv); /* Instantiate the ArgumentList with command line args. */ QString appname = al.takeFirst(); /* The first item in the list is the name of the executable */ qDebug() << "Running " << appname; bool verbose = al.getSwitch("-v"); bool testing = al.getSwitch("-t"); /* Now all switches have been removed from the list.Only filenames remain.*/ if (testing) { runTestOnly(al, verbose); /* ArgumentList can be used in place of QStringList. */ return 0; } else { qDebug() << "This Is Not A Test"; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -