在 MSVC 上使用 WxWidgets 时没有窗口出现

问题描述 投票:0回答:0

我在使用WxWidgets时遇到问题,我的代码如下:

#include <wx/wx.h>
#include <iostream>

class MyApp : public wxApp
{
public:
    virtual bool OnInit();
};

class MyFrame : public wxFrame
{
public:
    MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size);
};

bool MyApp::OnInit()
{
    MyFrame* frame = new MyFrame("Hello World", wxPoint(50, 50), wxSize(450, 340));
    frame->Show(true);
    return true;
}

MyFrame::MyFrame(const wxString& title, const wxPoint& pos, const wxSize& size)
    : wxFrame(NULL, wxID_ANY, title, pos, size)
{
}

wxIMPLEMENT_APP(MyApp);

int main()
{
    std::cout << "Hello world, why isn't there a window showing?\n";
}

它编译得很好,但除了输出之外没有窗口出现:

Hello world, why isn't there a window showing?
但它不显示任何 GUI 窗口。

我一直在 MSVC 上使用 vcpkg 来获取 WxWidgets,有人知道我如何解决这些错误吗?

c++ visual-c++ wxwidgets
© www.soinside.com 2019 - 2024. All rights reserved.