【发布时间】:2017-04-06 05:02:02
【问题描述】:
我正在尝试编写应用程序的另一部分调用的应用程序的 wxWidgets 组件,因此没有 wxWidgets 主程序。我在查找正确的调用顺序时遇到了一些问题。
据我了解,首先我需要继承wxApp:
class TestApp : public wxApp {
public:
virtual bool OnInit() override;
};
bool TestApp::OnInit() {
cerr << "app init\n"<<flush;
}
那我想启动wxWidgets的时候需要做这样的事情:
TestApp* app = new TestApp();
cerr << "a\n";
wxApp::SetInstance(app);
cerr << "b\n";
int argCount = 0;
char* argv[0];
if(! wxEntryStart(argCount, argv)) {
cerr << "wx failed to start\n";
wxExit();
}
cerr << "d\n";
int res = wxGetApp().OnRun();
但它从不调用OnInit()。有谁知道我应该做什么?
这个问题与wxWidgets: How to initialize wxApp without using macros and without entering the main application loop? 不同,因为他们不想 想要调用事件循环(所以他们想要wxEntryStart())但我做想要事件循环(所以,事实证明,我想要wxEntry())。
【问题讨论】: