我正在将 wxWidgets 用于我正在尝试制作的应用程序,现在此代码中的所有内容在技术上都可以正常工作,图像按预期显示,但是我创建的按钮仅出现在鼠标悬停在它们应该在的位置上之后。任何想法将不胜感激。 :) 解释为什么会发生这种情况也很有用。
#include "MainFrame.h"
#include <wx/wx.h>
MainFrame::MainFrame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title) {
wxPanel* Panel = new wxPanel(this); // creates the panel which the controls will be attached to
// forces the size of the frame to remain 800 x 800 as to not mess up any image formatting
this->SetClientSize(800, 800);
this->SetMinSize(GetSize());
this->SetMaxSize(GetSize());
// image handling
wxImage::AddHandler(new wxPNGHandler()); // this adds the images that are required to the panel.
wxBitmap ImageBitmap("pathToImage/backgroundfinal.png", wxBITMAP_TYPE_PNG);
// this tells the program where to fetch the image file
this->SetBackgroundColour("#c2cbc6"); // this sets the background colour of the window to the given hex code
wxStaticBitmap* GUIDisplay = new wxStaticBitmap(this, wxID_ANY, ImageBitmap, wxPoint(0, 0));//this positions the image in the frame
// fonts
wxFont StreakFont(36, wxFONTFAMILY_SWISS, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD);
// buttons
wxButton* TopicQuestion = new wxButton(Panel, wxID_ANY, "Topic Questions", wxPoint(300, 125), wxSize(245, 85));
wxButton* Flashcards = new wxButton(Panel, wxID_ANY, "Flashcards", wxPoint(300, 245), wxSize(245, 85));
wxButton* PopQuiz = new wxButton(Panel, wxID_ANY, "Pop Quiz", wxPoint(300, 365), wxSize(245, 85));
wxButton* Customisation = new wxButton(Panel, wxID_ANY, "Customisation", wxPoint(300, 485), wxSize(245, 85));
wxButton* Leaderboard = new wxButton(Panel, wxID_ANY, "Leaderboard", wxPoint(300, 605), wxSize(245, 85));
// text
wxStaticText* DailyStreak = new wxStaticText(this, wxID_ANY, "52", wxPoint(395, 10));
DailyStreak->SetFont(StreakFont);
}