Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/qt/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在显示此类封面的一般视图时,即如何在事件循环结束时运行某些内容,然后返回。@qt5 thisQObject::connect(task,&task::finished,&QCoreApplication::quit)中的baysmith似乎也能工作。QCo_C++_Qt_Console - Fatal编程技术网

C++ 在显示此类封面的一般视图时,即如何在事件循环结束时运行某些内容,然后返回。@qt5 thisQObject::connect(task,&task::finished,&QCoreApplication::quit)中的baysmith似乎也能工作。QCo

C++ 在显示此类封面的一般视图时,即如何在事件循环结束时运行某些内容,然后返回。@qt5 thisQObject::connect(task,&task::finished,&QCoreApplication::quit)中的baysmith似乎也能工作。QCo,c++,qt,console,C++,Qt,Console,在显示此类封面的一般视图时,即如何在事件循环结束时运行某些内容,然后返回。@qt5 thisQObject::connect(task,&task::finished,&QCoreApplication::quit)中的baysmith似乎也能工作。QCoreApplication::quit是一个槽:QTimer::singleShot(0,&a,槽(quit())为什么要包括main.moc?这里描述了必须包括main.moc的原因:这不使用Qt事件循环。它是一个裸Unix main()。


在显示此类封面的一般视图时,即如何在事件循环结束时运行某些内容,然后返回。@qt5 this
QObject::connect(task,&task::finished,&QCoreApplication::quit)中的baysmith似乎也能工作。
QCoreApplication::quit
是一个槽:
QTimer::singleShot(0,&a,槽(quit())
为什么要包括
main.moc
?这里描述了必须包括
main.moc
的原因:这不使用Qt事件循环。它是一个裸Unix main()。
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    return a.exec();
}
#include <QtCore>

int main()
{
    QVector<int> a; // Qt object

    for (int i=0; i<10; i++)
    {
        a.append(i);
    }

    /* manipulate a here */

    return 0;
}
CONFIG += console 
// main.cpp
#include <QtCore>

class Task : public QObject
{
    Q_OBJECT
public:
    Task(QObject *parent = 0) : QObject(parent) {}

public slots:
    void run()
    {
        // Do processing here

        emit finished();
    }

signals:
    void finished();
};

#include "main.moc"

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    // Task parented to the application so that it
    // will be deleted by the application.
    Task *task = new Task(&a);

    // This will cause the application to exit when
    // the task signals finished.    
    QObject::connect(task, SIGNAL(finished()), &a, SLOT(quit()));

    // This will run the task from the application event loop.
    QTimer::singleShot(0, task, SLOT(run()));

    return a.exec();
}
    #include <QtCore/QCoreApplication>
    #include <iostream>
    using namespace std;
    int main(int argc, char *argv[])
    {
     QCoreApplication a(argc, argv);
     cout<<" hello world";
     return a.exec();
     }
#include <QDebug>

int main(int argc, char *argv[])  
{
   qDebug() <<"Hello World"<< endl;
   return 0;
}
#include <QCoreApplication>
#include <QTimer>

int main(int argc, char *argv[])
{
    QCoreApplication app( argc, argv );

    // do your thing, once

    QTimer::singleShot( 0, &app, &QCoreApplication::quit );
    return app.exec();
}