[更新] OK、以前の質問を更新しています。widgets
最初は、.pro ファイルから削除すると警告が表示されると思っていましたが、これは奇妙な動作でした。掘り下げた後、完全に空のアプリケーションになり、問題はまだ解決していません。私のアプリケーションは次のようになります。
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
return app.exec();
}
同様の問題を抱えた他の投稿に基づいてQApplication
、最初に初期化する必要があることを知りました。この場合、アプリケーションには他に何もありません。この警告はどのように表示されますか?
W/ (16992): (null):0 ((null)): WARNING: QApplication was not created in the main() thread.
Android for x86 (GCC 4.9, Qt 5.6.0)
キットを使用して、Android デバイスでアプリケーションを直接コンパイルしています。
---- 古い質問\開始 ----
現在、Qt 5.6 (C++ および QML) に基づく Android アプリを開発中です。UI は QtQuick に基づいているため、pro.file から「ウィジェット」を削除しました。
QT += core qml quick widgets network svg xml gui
これにより、次の警告が表示されます。
WARNING: QApplication was not created in the main() thread.
また... main() で QQmlEngine をインスタンス化するとすぐに (もちろん QApplication を作成した後)、この警告も表示されます。
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QQmlDebuggerServiceFactory(0x65fffcd0), parent's thread is QThread(0x5d449f10), current thread is QThread(0x65183000)
明らかに、アプリケーションは別のスレッドで起動しますか? と main() 別の?「ウィジェット」を .pro ファイルに入れるとすぐに、両方のエラーが表示されなくなりました。私は本当に2つのことの間の相関関係を理解していません。PSはプログラムのこの段階ではあまり関係ありませんが、アプリケーションで新しいスレッドを作成していません。 これは私の main() がどのように見えるかです:
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
qmlRegisterUncreatableType<MainFrame>("PSGApp", 1, 0, "MainFrame", "");
MainFrame m_MainFrame;
QQmlEngine engine;
engine.rootContext()->setContextProperty("q_MainFrame", &m_MainFrame);
engine.rootContext()->setContextProperty("Ctr", m_MainFrame.c());
engine.rootContext()->setContextProperty("Dev", m_MainFrame.c()->dev());
engine.rootContext()->setContextProperty("Def", m_MainFrame.c()->dev()->_def());
engine.rootContext()->setContextProperty("ModelUdpDevices", m_MainFrame.UdpDevices());
engine.rootContext()->setContextProperty("ModelDashboardDevices", m_MainFrame.DashboardDevices());
engine.rootContext()->setContextProperty("ModelZones", m_MainFrame.c()->dev()->_DevZones());
engine.rootContext()->setContextProperty("ModelRGParameter", m_MainFrame.c()->dev()->RegelParameter());
engine.rootContext()->setContextProperty("ModelSYSParameter", m_MainFrame.c()->dev()->SysParameter());
engine.rootContext()->setContextProperty("ModelKOMMParameter", m_MainFrame.c()->dev()->KommParameter());
QObject::connect(&app, SIGNAL(applicationStateChanged(Qt::ApplicationState)), &m_MainFrame, SLOT(applicationStateChanged(Qt::ApplicationState)));
QObject::connect(&engine, SIGNAL(quit()), &app, SLOT(quit()));
QQmlComponent component(&engine,QUrl(QStringLiteral("qrc:/qml/main.qml")));
component.create();
return app.exec();
}
---- 古い質問\終わり ----