main.cpp
来自「压缩包里有教材<<C++模式设计-基于QT4开源跨平台开发框架>」· C++ 代码 · 共 38 行
CPP
38 行
#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 + =
减小字号Ctrl + -
显示快捷键?