Compile Error(C2440)Using CEFbrowser & VS2015

纵然是瞬间 提交于 2020-08-10 19:18:18

问题


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;
  }

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!


回答1:


It looks like your CefClient has to inherit from CefDownloadHandler, i.e. class CefClient: public virtual CefBase, public CefDownloadHandler: CEF C++ Implementing download handler

Once you inherit from CefDownloadHandler, returning this from an instance of CefClient will fit correctly as a CefRefPtr<CefDownloadHandler>.



来源:https://stackoverflow.com/questions/62912066/compile-errorc2440using-cefbrowser-vs2015

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!