Invalid conversion error

The compiler keeps on telling me that invalid conversion from wxBitmap* to wxString on the line with the AddTool function, whiles I do not even try to do such an ambigiuos typecast. Please show me the problem.
wxWidgets 2.9.4
MinGW
gdb

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/********************************************************************
aim:
-
********************************************************************/
//headers
#include "mainwnd.h"

//namespaces

//other definitions and declarations
CMAINWND::CMAINWND(const wxString& szTitle):wxFrame(NULL,wxID_ANY,szTitle)
{
    wxImage::AddHandler(new wxBMPHandler);
    wxBitmap *exitButtImg=new wxBitmap(wxT("icon_32x32.bmp"),wxBITMAP_TYPE_BMP);
    wxToolBar *toolBar=CreateToolBar(wxTB_DOCKABLE|wxTB_HORIZONTAL|wxBORDER_NONE);
    toolBar->AddTool((int)wxID_EXIT,exitButtImg,(wxString)wxT("Close"));
    toolBar->Realize();
    wxImage::CleanUpHandlers();
    CentreOnScreen();
}


Thanks,
Aceix.
Check the declaration of AddTool
Hi, these are the implementations of wxToklBar::AddTool
wxToolBar::AddTool
wxToolBarToolBase* AddTool(int toolId, const wxString& label, const wxBitmap& bitmap1, const wxString& shortHelpString = "", wxItemKind kind = wxITEM_NORMAL)

wxToolBarToolBase* AddTool(int toolId, const wxString& label, const wxBitmap& bitmap1, const wxBitmap& bitmap2 = wxNullBitmap, wxItemKind kind = wxITEM_NORMAL, const wxString& shortHelpString = "", const wxString& longHelpString = "", wxObject* clientData = NULL)

wxToolBarToolBase* AddTool(wxToolBarToolBase* tool)



Aceix.
In all definition second parameter is wsString reference. And you declared exitButtImg as a pointer to wxBitmap two lines earlier.
Trying that...

Aceix.
I swapped them but problem still persists.

Aceix.
Last edited on
What exactly did you do and what error is happening now?
I changed it to: toolBar->AddTool((int)wxID_EXIT,(wxString)wxT("Close"),exitButtImg);

But the same error showed up.
Nevermind, when I changed the exitButtImg to a simple object(ie: not a pointer), it now compiles.

Thanks for the help,
Aceix.
That because function takes reference not a pointer. You could pass it like *exitButtImg
Topic archived. No new replies allowed.