Object created in main not in QApplication's t

2019-03-05 04:38发布

问题:

I have an issue I'm trying to deal with since 2 days now:

int main(int argc, char *argv[])
{
    qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard"));
    qputenv("QT_VIRTUALKEYBOARD_STYLE", QByteArray("MacoUV"));

    QApplication app(argc, argv);

    int result;

    MacoUVController * pController = new MacoUVController();

    pController->start();

    result = app.exec();         
    return result;
}

When I display the pController thread in the console:

std::cout << "MacoUV Controller thread: " << pController->thread() <<std::endl;
std::cout << "MacoUV Controller thread: " << qApp->instance()->thread() <<std::endl;

I have two different thread addresses displayed, I can't understand why, since all object are normally created in the main thread until you explicitly move them(by using moveToThread for example) into another thread.

Any explanation about this issue ?

标签: c++ qt qthread