(wxwidget c++)保存用户输入
当用户更改滑块上的值并命中输入时,我正在尝试保存用户输入,或者我可以在用户输入一个数字的文本框中,但这是在wxwidget中保存为字符串的,这是一个问题,因为值需要成为整数。
向用户提供了此处, window 1 ,然后, window 2 ,在输入我需要的值...
这是我的代码:
using namespace std;
Frame::Frame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title)
{
}
void Frame::OnButton1(wxCommandEvent&)
{
Close();
Gas Air(1.4, 287);
Frame* Window_Oblique = new Frame("Oblique Shock Calculator");
Window_Oblique->SetClientSize(500, 400);
wxStaticText* Question = new wxStaticText(Window_Oblique, wxID_ANY, "Enter Oblique Shock Mach 1", wxPoint(175, 50));
/*xTextCtrl* textCtrl = new wxTextCtrl(Window_Oblique, wxID_ANY, "Enter Mach 1", wxPoint(150, 100), wxSize(200, -1));*/
wxSpinCtrl* spinCtrl = new wxSpinCtrl(Window_Oblique, wxID_ANY, "", wxPoint(200, 100), wxSize(50, -1));
wxButton* Button5 = new wxButton(Window_Oblique, 5, "Enter", wxPoint(250, 101), wxSize(35, 20));
int MachNumber1_normalShock = spinCtrl->GetValue();
NormalShock normShock1;
normShock1.setGamma(Air.getGamma());
normShock1.setGasConstant(Air.getGasConstant());
normShock1.setMachNumber1(MachNumber1_normalShock);
normShock1.calculatePressureRatio();
cout << normShock1.getPressureRatio() << endl;
normShock1.calculateDensityRatio();
cout << normShock1.getDensityRatio() << endl;
normShock1.calculateTemperatureRatio();
cout << normShock1.getTemperatureRatio() << endl;
normShock1.calculateMachNumber2();
cout << normShock1.getMachNumber2() << endl;
Window_Oblique->Show();
}
void Frame::OnButton2(wxCommandEvent&)
{
Close();
Frame* Window_Normal = new Frame("Normal Shock Calculator");
Window_Normal->SetClientSize(500, 400);
wxStaticText* Question = new wxStaticText(Window_Normal, wxID_ANY, "Enter Normal Shock Details", wxPoint(250, 50));
Window_Normal->Show();
}
void Frame::OnButton3(wxCommandEvent&)
{
Close();
Frame* Window_Isen = new Frame("Isentropic Flow Calculator");
Window_Isen->SetClientSize(500, 400);
wxStaticText* Question = new wxStaticText(Window_Isen, wxID_ANY, "Enter Isnetropic Flow Details", wxPoint(130, 50));
Window_Isen->Show();
}
void Frame::OnButton4(wxCommandEvent&)
{
Close();
Frame* Window_Expansion = new Frame("Expansion Fan Calculator");
Window_Expansion->SetClientSize(500, 400);
wxStaticText* Question = new wxStaticText(Window_Expansion, wxID_ANY, "Enter Expansion Fan Details", wxPoint(130, 50));
Window_Expansion->Show();
}
void Frame::OnQuit(wxCommandEvent&)
{
Close();
}
BEGIN_EVENT_TABLE(Frame, wxFrame)
EVT_BUTTON(1, Frame::OnButton1)
EVT_BUTTON(2, Frame::OnButton2)
EVT_BUTTON(3, Frame::OnButton3)
EVT_BUTTON(4, Frame::OnButton4)
EVT_BUTTON(wxID_EXIT, Frame::OnQuit)
END_EVENT_TABLE()
'''''
I am trying to save user input when the user changes a value on a slider and hits enter, or I can have a text box where the user inputs a number, but this is saved as a string in wxWidget which is a problem because the value needs to be an integer.
The user is presented with this, Window 1, then this,Window 2, where the value I need is inputted...
Here is my code:
using namespace std;
Frame::Frame(const wxString& title) : wxFrame(nullptr, wxID_ANY, title)
{
}
void Frame::OnButton1(wxCommandEvent&)
{
Close();
Gas Air(1.4, 287);
Frame* Window_Oblique = new Frame("Oblique Shock Calculator");
Window_Oblique->SetClientSize(500, 400);
wxStaticText* Question = new wxStaticText(Window_Oblique, wxID_ANY, "Enter Oblique Shock Mach 1", wxPoint(175, 50));
/*xTextCtrl* textCtrl = new wxTextCtrl(Window_Oblique, wxID_ANY, "Enter Mach 1", wxPoint(150, 100), wxSize(200, -1));*/
wxSpinCtrl* spinCtrl = new wxSpinCtrl(Window_Oblique, wxID_ANY, "", wxPoint(200, 100), wxSize(50, -1));
wxButton* Button5 = new wxButton(Window_Oblique, 5, "Enter", wxPoint(250, 101), wxSize(35, 20));
int MachNumber1_normalShock = spinCtrl->GetValue();
NormalShock normShock1;
normShock1.setGamma(Air.getGamma());
normShock1.setGasConstant(Air.getGasConstant());
normShock1.setMachNumber1(MachNumber1_normalShock);
normShock1.calculatePressureRatio();
cout << normShock1.getPressureRatio() << endl;
normShock1.calculateDensityRatio();
cout << normShock1.getDensityRatio() << endl;
normShock1.calculateTemperatureRatio();
cout << normShock1.getTemperatureRatio() << endl;
normShock1.calculateMachNumber2();
cout << normShock1.getMachNumber2() << endl;
Window_Oblique->Show();
}
void Frame::OnButton2(wxCommandEvent&)
{
Close();
Frame* Window_Normal = new Frame("Normal Shock Calculator");
Window_Normal->SetClientSize(500, 400);
wxStaticText* Question = new wxStaticText(Window_Normal, wxID_ANY, "Enter Normal Shock Details", wxPoint(250, 50));
Window_Normal->Show();
}
void Frame::OnButton3(wxCommandEvent&)
{
Close();
Frame* Window_Isen = new Frame("Isentropic Flow Calculator");
Window_Isen->SetClientSize(500, 400);
wxStaticText* Question = new wxStaticText(Window_Isen, wxID_ANY, "Enter Isnetropic Flow Details", wxPoint(130, 50));
Window_Isen->Show();
}
void Frame::OnButton4(wxCommandEvent&)
{
Close();
Frame* Window_Expansion = new Frame("Expansion Fan Calculator");
Window_Expansion->SetClientSize(500, 400);
wxStaticText* Question = new wxStaticText(Window_Expansion, wxID_ANY, "Enter Expansion Fan Details", wxPoint(130, 50));
Window_Expansion->Show();
}
void Frame::OnQuit(wxCommandEvent&)
{
Close();
}
BEGIN_EVENT_TABLE(Frame, wxFrame)
EVT_BUTTON(1, Frame::OnButton1)
EVT_BUTTON(2, Frame::OnButton2)
EVT_BUTTON(3, Frame::OnButton3)
EVT_BUTTON(4, Frame::OnButton4)
EVT_BUTTON(wxID_EXIT, Frame::OnQuit)
END_EVENT_TABLE()
'''
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论