当前位置: 首页>>代码示例>>C++>>正文


C++ QApplication::argc方法代码示例

本文整理汇总了C++中QApplication::argc方法的典型用法代码示例。如果您正苦于以下问题:C++ QApplication::argc方法的具体用法?C++ QApplication::argc怎么用?C++ QApplication::argc使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QApplication的用法示例。


在下文中一共展示了QApplication::argc方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main( int argc, char **argv )
{
    QApplication::setColorSpec( QApplication::CustomColor );
    QApplication * a = new QApplication( argc, argv );
    
    QString appname( "xpracman" );
    QString applabel( "XpracMan" );
    ::XpracManDir = getenv("PRAC_DIR");
    if ( !XpracManDir.length() )
        XpracManDir = QMVAPPLICATIONDIR;
    
    QString dbname = getenv( "PGDATABASE" );
    QString dbaccessname = getenv( "MARVINACCESS" );
    QString dbhost = getenv( "PGHOST" );
    QString dbport = getenv( "PGPORT" );
    
    int debug = 0;
    int wapp = 800;
    int happ = 600;
    bool maximize = false;
    
    for ( int i = 1; i < a->argc(); i++ )
    {
        if ( QString( a->argv()[i] ) == "--debug" )
        {
            debug = 1;
            continue;
        }
        if ( QString( a->argv()[i] ) == "--maximize" )
        {
            maximize = true;
            continue;
        }
        qDebug( "main: argument # %d <%s>", i, a->argv()[i] );
        if ( QString( a->argv()[i] ) == "--pracdir" )
        {
            ++i;
            XpracManDir = QString( a->argv()[i] );
            continue;
        }
        if ( QString( a->argv()[i] ) == "--database" )
        {
            ++i;
            dbname = QString( a->argv()[i] );
            continue;
        }
        if ( QString( a->argv()[i] ) == "--database-host" )
        {
            ++i;
            dbhost = QString( a->argv()[i] );
            continue;
        }
        if ( QString( a->argv()[i] ) == "--database-port" )
        {
            ++i;
            dbport = QString( a->argv()[i] );
            continue;
        }
        if ( QString( a->argv()[i] ) == "--accessdb" )
        {
            ++i;
            dbaccessname = QString( a->argv()[i] );
            continue;
        }
        if ( QString( a->argv()[i] ) == "--applabel" )
        {
            ++i;
            applabel = QString( a->argv()[i] );
            continue;
        }
        
        QMessageBox::critical( 0, QString( "%1: Illegal argument:fatal" ).arg( appname ),
                               QString( "An unknown argument was detected.\n\n %1\n\n"
                                        "This application will now exit." )
                               .arg( QString( a->argv()[i] ) ) );
        exit(1);
        
    }

        // Start a splash screen asap
    
    QProgressDialog splash( QString("Starting %1...").arg(applabel), "Abort", 100, 0, "progress", TRUE );
    splash.setProgress( 10 );
    qApp->processEvents();
    if ( splash.wasCancelled() )
        exit(1);
    
    if ( !debug )
        qInstallMsgHandler( messageHandler );

        // ------------------------------------------------------------
        // Settle on an access database name
        // ------------------------------------------------------------
    if ( dbaccessname.isNull() || dbaccessname.length() < 1 )
        if ( dbname.isNull() || dbname.length() < 1 )
            dbaccessname = QString("marvin_access");
        else
            dbaccessname = dbname;

        // ------------------------------------------------------------
//.........这里部分代码省略.........
开发者ID:py1668,项目名称:xpracman-qt2-final,代码行数:101,代码来源:main.cpp


注:本文中的QApplication::argc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。