Search code examples
c++user-interfacedata-structureswxwidgetsdatastore

Store strings as wstring or wxString in wxWidgets?


I have to store many strings in class Language. I store them as std::wstring. And in GUI part I'd display them in wxListBox. As I know, wxWidgets deals with wxString. So, how have I to store strings in Language by wxString instead of default std::wstring ? They said it is better, then logic part of code doesn't know anything aboud GUI part.


Solution

  • From the wxWidgets documentation:

    While the use of wxString is unavoidable in wxWidgets program, you are encouraged to use the standard string classes std::string or std::wstring in your applications and convert them to and from wxString only when interacting with wxWidgets.

    wxString has a converting constructor from std::wstring (amongst other things), so you can easily make one when you need one.