【问题标题】:Compile Error(C2440)Using CEFbrowser & VS2015编译错误(C2440)使用 CEFbrowser & VS2015
【发布时间】:2020-07-15 09:45:08
【问题描述】:

那里。我是 CEFbrowser 的新手。 我正在开发 My CefBrowser 的下载模型。 我写了一些代码,但编译时出错。

 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:

"return":cannot convert from 'CefClient *const' to 'CefRefPtr<CefDownloadHandler>'

我是新来的。当我将return this 更改为return null 时,它会运行,但无法下载。 我能做些什么来解决这个问题? 谢谢!

【问题讨论】:

  • 看起来你的CefClient 必须继承自CefDownloadHandler,即class CefClient: public virtual CefBase, public CefDownloadHandlerstackoverflow.com/q/57198461/260313
  • 好的,我试试这个。谢谢!
  • 谢谢!这真的有效。我的问题已经解决了。
  • emm,如果你回答这个问题会更好,我会接受答案。
  • 我很高兴它有帮助。好的,我会的!

标签: c++ visual-studio-2015 chromium-embedded


【解决方案1】:

看起来您的CefClient 必须继承自CefDownloadHandler,即class CefClient: public virtual CefBase, public CefDownloadHandlerCEF C++ Implementing download handler

一旦您从CefDownloadHandler 继承,从CefClient 的实例返回this 将与CefRefPtr&lt;CefDownloadHandler&gt; 正确匹配。

【讨论】:

  • 太棒了!谢谢!
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-01
  • 2017-01-26
  • 2015-11-27
  • 2022-11-25
相关资源
最近更新 更多