在文本框中显示值 - 错误

时间:2012-07-19 07:23:39

标签: c++ wxwidgets

我有       size_t sums [4] = {0,0,0,0};

和一个文本框,我在其中试图显示我对其完成一些操作后得到的值。值是sums [i],但是现在我想在文本框中显示值,我这样做:

  *TextBox4 << "hello" << size_t sums;

frame->Connect(TEXT_BOX4, wxEVT_COMMAND_BUTTON_CLICKED | wxEVT_COMMAND_ENTER, (wxObjectEventFunction) & MyFrame::OnGenerateKey);

TextBox4 = new wxTextCtrl(this, TEXT_BOX4, wxT(""), wxPoint(200, 200), wxSize(200, 20), wxTE_PROCESS_ENTER | wxTE_READONLY | wxTE_LEFT, wxDefaultValidator, wxT("WxTextBox4"));

然而它会产生以下错误

 base.cpp:212:22: error: ambiguous overload for 'operator<<' in '*((MyFrame*)this)->MyFrame::TextBox4 << sum'
base.cpp:212:22: note: candidates are:
C:\wxWidgets-2.8.12\include/wx/textctrl.h:419:17: note: wxTextCtrl& wxTextCtrlBase::operator<<(const wxString&)
C:\wxWidgets-2.8.12\include/wx/textctrl.h:420:17: note: wxTextCtrl& wxTextCtrlBase::operator<<(int)
C:\wxWidgets-2.8.12\include/wx/textctrl.h:421:17: note: wxTextCtrl& wxTextCtrlBase::operator<<(long int)
C:\wxWidgets-2.8.12\include/wx/textctrl.h:422:17: note: wxTextCtrl& wxTextCtrlBase::operator<<(float)
C:\wxWidgets-2.8.12\include/wx/textctrl.h:423:17: note: wxTextCtrl& wxTextCtrlBase::operator<<(double)
C:\wxWidgets-2.8.12\include/wx/textctrl.h:424:17: note: wxTextCtrl& wxTextCtrlBase::operator<<(wxChar)

请帮帮我。

1 个答案:

答案 0 :(得分:1)

首先,你不能打印这样的静态数组,你需要迭代它。第二 - 你应该只打印没有类型的总和:

  

* TextBox4&lt;&lt; “你好”&lt;&lt;款项;

这仍然不足以帮助你 - 我需要更多的背景。