wxWidgets Drop Files事件处理程序初始化问题(无效的static_cast)

问题描述 投票:0回答:1

[我正在尝试制作一个简单的程序,使用带有(wxWidgets)wxListCtrl的C ++将文件拖放到列表中。

我是C ++和wxWidgets的初学者,在wxwidgets dnd示例中搜索2074行代码远远超出了我目前的能力。 (很抱歉)

我使用的工具:代码:: Blocks 20.03,MinGW 17.1,wxWidgets 3.1.3,wxFormBuilder 3.9.0。操作系统:Windows 10 Pro。

我尝试了以下操作:(在SetupnGUI()函数中,该函数在DnD_SimpleFrame类构造函数中调用。)]

m_listCtrl1 = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_NO_HEADER|wxLC_REPORT );
m_listCtrl1->DragAcceptFiles(true);
m_listCtrl1->Connect(wxEVT_DROP_FILES, wxDropFilesEventHandler(DnD_SimpleFrame::OnDropFiles), NULL, this);

删除文件时(从资源管理器中调用的函数是:

bool DnD_SimpleFrame::OnDropFiles(wxArrayString &filenames)
{
    size_t nFiles = filenames.GetCount();
    wxString str;
    str.Printf( "%d files dropped", (int)nFiles);

    m_listCtrl1->DeleteAllItems();
    if (m_listCtrl1 != NULL)
    {
        m_listCtrl1->InsertItem(0, str);
        for ( size_t n = 1; n < (nFiles+1); n++ )
            m_listCtrl1->InsertItem(n, filenames[n]);
    }
    return true;
}

m_listCtrl1-> Connect(...)上的构建消息;行是:

||=== Build: Debug in DnD_Simple (compiler: GNU GCC Compiler) ===|
F:\Data\__C++\wxApps\DnD_Simple\DnD_SimpleMain.cpp||In member function 'void DnD_SimpleFrame::SetupGUI()':|
F:\SDKs\wx313\include\wx\event.h|149|error: invalid static_cast from type 'bool (DnD_SimpleFrame::*)(wxArrayString&)' to type 'wxDropFilesEventFunction' {aka 'void (wxEvtHandler::*)(wxDropFilesEvent&)'}|
F:\SDKs\wx313\include\wx\event.h|4196|note: in expansion of macro 'wxEVENT_HANDLER_CAST'|
F:\Data\__C++\wxApps\DnD_Simple\DnD_SimpleMain.cpp|92|note: in expansion of macro 'wxDropFilesEventHandler'|
||=== Build failed: 1 error(s), 0 warning(s) (0 minute(s), 1 second(s)) ===|

我希望有人会这么友好,并在这里解释我做错了(或忘记了)?

谢谢你。

Ruud

我正在尝试制作一个简单的程序,使用带有(wxWidgets)wxListCtrl的C ++将文件拖放到列表中。我是C ++和wxWidgets的初学者,正在wxwidgets的2074行代码中搜索... ...

c++ wxwidgets
1个回答
0
投票

如果您仔细查看错误消息:

© www.soinside.com 2019 - 2024. All rights reserved.