0

在此处输入图像描述

在 wxWidgets 中,我初始化了一个名为numpad的Grid Sizer。我有我的wxButtons数组命名为numbers。我只希望我的 GridSizer 有均匀的空间,正如你在我设置的图像中看到的那样,GUI 中的空间仍然看起来不均匀。SetHGap(10)SetVGap(10)

    wxBoxSizer* vertiSizer = new wxBoxSizer(wxVERTICAL);
    wxBoxSizer* horiSizer = new wxBoxSizer(wxHORIZONTAL);
    calcArea = new wxTextCtrl(this, CALCAREA, "", wxPoint(0,0), wxSize(100,60));
    calcArea->SetFont(wxFont(21, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
    
    numbers = new wxButton*[10];
    wxGridSizer* numpad = new wxGridSizer(3, 3, wxSize(0,0));    
    for(int i = 0; i < 3; i++){
        
        for(int j = 0; j < 3; j++){
            numbers[i*3+j] = new wxButton(this, wxID_ANY, std::to_string(i*3+j+1), wxPoint(0,0), wxSize(70, 80));
            numbers[i*3+j]->SetFont(wxFont(20, wxFONTFAMILY_MODERN, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));
            
            numpad->Add(numbers[i*3+j], 0, wxFIXED | wxALL, 0);
            
            
        }
        
    }
    numpad->SetHGap(10);
    numpad->SetVGap(10);
    
    
    
    vertiSizer->Add(calcArea, 0, wxEXPAND | wxALL, 4);

    vertiSizer->Add(numpad, 0,  wxSHAPED| wxLEFT, 10);
    
    
    this->SetSizer(vertiSizer, true);
4

0 回答 0