Hi,
I have been checking how portable wxwidgets can be. For this, I’m trying to run the following code:
toolbar.h :
#include <wx/wx.h>
class Toolbar : public wxFrame
{
public:
Toolbar(const wxString& title);
void OnQuit(wxCommandEvent& event);
};
toolbar.cpp :
#include "toolbar.h"
Toolbar::Toolbar(const wxString& title)
: wxFrame(NULL, wxID_ANY, title, wxDefaultPosition, wxSize(280, 180))
{
wxBitmap exit(wxT("print.png"));
wxToolBar *toolbar = CreateToolBar();
toolbar->AddTool(wxID_EXIT, exit, wxT("Exit application"));
toolbar->Realize();
Connect(wxID_EXIT, wxEVT_COMMAND_TOOL_CLICKED,
wxCommandEventHandler(Toolbar::OnQuit));
Centre();
}
void Toolbar::OnQuit(wxCommandEvent& WXUNUSED(event))
{
Close(true);
}
main.h :
#include <wx/wx.h>
class MyApp : public wxApp
{
public:
virtual bool OnInit();
};
main.cpp :
#include "main.h"
#include "toolbar.h"
IMPLEMENT_APP(MyApp)
bool MyApp::OnInit()
{
Toolbar *toolbar = new Toolbar(wxT("Toolbar"));
toolbar->Show(true);
return true;
}
And in terminal I type:
g++ main.cpp main.h toolbar.cpp toolbar.h `wx-config --cxxflags --libs` -o toolbartest
Then I can run the application, but no toolbar is shown. Anyone knows why?
Thanks in advance.