问题描述
有。我是CEFbrowser的新手。
我正在开发My CefBrowser的下载模型。
我写了一些代码,但是编译时出错。
there. I'm new to CEFbrowser.I'm developing the download model of My CefBrowser.I've written some code but error while compiling.
class CefClient : public virtual CefBase { public: /// // Return the handler for download events. If no handler is returned downloads // will not be allowed. /// /*--cef()--*/ virtual CefRefPtr<CefDownloadHandler> GetDownloadHandler(){ return this; }
但是VS2015表示C2440:
But VS2015 says C2440:
"return":cannot convert from 'CefClient *const' to 'CefRefPtr<CefDownloadHandler>'
我是新来的。当我将退回此到返回空时,它会运行,但无法下载 。
我该怎么做才能解决这个问题?
谢谢!
I'm new. and when i change return this to return null it runs, but can't download.What can i do to solve this problem?Thank you!
推荐答案
您的 CefClient 必须从 CefDownloadHandler 继承,即类CefClient:公共虚拟CefBase,公共CefDownloadHandler :
It looks like your CefClient has to inherit from CefDownloadHandler, i.e. class CefClient: public virtual CefBase, public CefDownloadHandler: CEF C++ Implementing download handler
一旦您从 CefDownloadHandler ,从 CefClient 的实例返回 this 将正确地作为 CefRefPtr< CefDownloadHandler> 。
Once you inherit from CefDownloadHandler, returning this from an instance of CefClient will fit correctly as a CefRefPtr<CefDownloadHandler>.
这篇关于使用CEFbrowser&编译错误(C2440) VS2015的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!