Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ember.js/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 将行尾写入WXTEXTCRL_C++_Wxwidgets - Fatal编程技术网

C++ 将行尾写入WXTEXTCRL

C++ 将行尾写入WXTEXTCRL,c++,wxwidgets,C++,Wxwidgets,我试图将文本写入wxWidgets应用程序中的wxtctrl对象。下面是示例代码。由于某种原因,我没能设法换行。我在网上找到的大多数例子都做了一件在这里不起作用的事情 守则: #include "wx/wx.h" using namespace std; class MainWindow : public wxFrame { public: MainWindow(const wxString& title); wxTextCtrl* textctrl; }; class

我试图将文本写入
wxWidgets
应用程序中的
wxtctrl
对象。下面是示例代码。由于某种原因,我没能设法换行。我在网上找到的大多数例子都做了一件在这里不起作用的事情

守则:

#include "wx/wx.h"

using namespace std;

class MainWindow : public wxFrame {
 public:
  MainWindow(const wxString& title);
  wxTextCtrl* textctrl;
};

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

MainWindow::MainWindow(const wxString& title)
    : wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180)) {
  // Add text window:
  textctrl =
      new wxTextCtrl(this, -1, wxT(""), wxPoint(-1, -1), wxSize(250, 150));

  // This writes to the middle of the text white space, but does not understand
  // endl \n or \r\n
  ostream log_stream(textctrl);
  log_stream << "Hey Joe! \n";
  log_stream << "Buckle up!\r\n";
  log_stream << "Lorem ipsum dolor sit amet" << endl;

  wxStreamToTextRedirector redirect(textctrl);
  cout << "Not yet " << endl;
  cout << "One more \n";
  cout << "Just one more \r\n";

  cout << "Fine, I quit.";

  Centre();
}
#包括“wx/wx.h”
使用名称空间std;
类主窗口:公共wxFrame{
公众:
主窗口(常量WX字符串和标题);
wxTextCtrl*textctrl;
};
MyApp类:公共wxApp{
公众:
虚拟bool-OnInit();
主窗口*主窗口;
};
主窗口::主窗口(常量wxString和标题)
:wxFrame(NULL,wxID_ANY,title,wxDefaultPosition,wxSize(280,180)){
//添加文本窗口:
文本控制=
新的wxtxtCtrl(this,-1,wxT(“”),wxPoint(-1,-1),wxSize(250150));
//这会写入文本中间的空白处,但无法理解
//endl\n或\r\n
ostream日志流(textctrl);

日志流您需要使用
wxTE\u MULTILINE
样式创建
wxTextCtrl
。然后您通常只需要
\n
,这将为每个平台正确解释。

您需要使用
wxTextCtrl
样式创建
wxTextCtrl
。然后您通常只需要
\n
,这将是正确的对每个平台进行详细解释