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!
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>.
Related
This is my class structure:
class B : public std::enable_shared_from_this<B> {
}
class A : public std::enable_shared_from_this<A> {
shared_ptr<B> b_;
void SomeFunction();
}
I'm getting an error on this line:
void A::SomeFunction() {
auto a_copy = shared_from_this();
}
The error text is:
error: no matching member function for call to 'shared_from_this'
When I remove the shared_ptr<B> b_; line from class A everything works fine..
I'm guessing that there are some requirements on the object I'm trying to enable_shared_from_this on, but I tried all sorts of things and searched for the error message but to no avail..
Do you have any idea?
Well, a little embarrassing..
The problem was that I wrote shared_ptr<B> b_ instead of std::shared_ptr<B> b_. My IDE (Android Studio) didn't highlight this error in the editor, and also in the build output it didn't present the error with a link to that line, so I just skipped that line and saw only the following bug, which of course stated that there is no such function for this unknown type. I guess I got too used to the convenience of the IDE :)
Leaving this here in case someone else misses this..
I am new in Qt.
I am trying to add texture to the example project "basicshapes", which comes from Qt Creator demo.
It is written in C++ that'w perfect, because it is my need.
There are used classes such as:
Qt3D::QTransform
Qt3D::QSphereMesh
Qt3D::QPhongMaterial
and many others
but I can not realize how to add texture to it.
There is a fragment:
Qt3D::QPhongMaterial *sphereMaterial = new Qt3D::QPhongMaterial();
sphereMaterial->setDiffuse(QColor(QRgb(0xa69929)));
so I was trying to add:
MyTextureImage *t = new MyTextureImage();
MyTextureProvider *x = new MyTextureProvider();
x->addTextureImage(t);
sphereMaterial->setTextureParameter("SphereTexture", x);
before I have derived from abstract classes:
class MyTextureProvider : public Qt3D::QAbstractTextureProvider { };
class MyTextureImage : public Qt3D::QAbstractTextureImage { };
but I got error:
error: C2259: 'MyTextureImage' : cannot instantiate abstract class
due to following members:
'Qt3D::QNode *Qt3D::QNode::doClone(void) const' : is abstract
I am not an expert of Qt, however by looking at the compiler error, you would need to override the doClone method because it is qualified as pure virtual.
More information on your compiler error can be found on MSDN: https://msdn.microsoft.com/en-us/library/zxt206sk.aspx
I hope this helps.
I'm currently writing an application using MFC and CLR in visual studio, and my program is crashing whenever I call the constructor of a class I've written (the class is to control a camera over USB).
I've got a base class CameraBase:
class CameraBase
{
public:
virtual bool getFrame(cv::Mat& outImage) { return true; };
};
and a derived class LumeneraCamera (for the specific camera):
class LumeneraCamera : public CameraBase
{
public:
DLL_API LumeneraCamera();
DLL_API bool connect(int cameraNum);
DLL_API bool disconnect();
DLL_API bool getFrame(cv::Mat& outImage);
private:
//Bunch of misc variables
};
These classes are compiled into a DLL and accessed from another program:
int main()
{
cout << "Initing camera" << endl;
camera = new LumeneraCamera();
//More operations
}
When I run the program, it prints Initing camera and then fails because of an assertion in dllinit.cpp (line 133: VERIFY(AfxInitExtensionModule(controlDLL, hInstance));). It crashes before executing anything in the constructor. I'm not really sure what the problem is but it seems tied to MFC, so I'm currently looking into untangling my project from MFC entirely. Any suggestions or fixes are appreciated!
According to MSDN, if your DLL is dynamically linked against the MFC DLLs, each function exported from this DLL which call into MFC must have the AFX_MANAGE_STATE macro added at the very beginning of the function:
AFX_MANAGE_STATE(AfxGetStaticModuleState());
I eventually solved it by disabling MFC - a library I was using suggested MFC but as far as I can tell works fine without it.
I am writing a C++ WinRT Component DLL for use in my .NET-based WinRT application. The DLL defines a SoundSample ref class that creates an XAudio voice by calling IXAudio2::CreateSourceVoice. CreateSourceVoice takes a "IXAudio2VoiceCallback *pCallback" parameter to enable callbacks on various audio events. Now I am trying to implement that callback based on this article. XAudio will supposedly just call back into methods of my SoundCallback class defined as:
#pragma once
#include "xaudio2.h"
#include "pch.h"
class SoundCallback
: public IXAudio2VoiceCallback
{
private:
//SoundSample^ sample; //does not compile
public:
SoundCallback(void);
~SoundCallback(void);
//Called when the voice has just finished playing a contiguous audio stream.
void OnStreamEnd();
void OnVoiceProcessingPassEnd();
void OnVoiceProcessingPassStart(UINT32 SamplesRequired);
void OnBufferEnd(void * pBufferContext);
void OnBufferStart(void * pBufferContext);
void OnLoopEnd(void * pBufferContext);
void OnVoiceError(void * pBufferContext, HRESULT Error);
};
Everything is fine until I try to figure out how to call back from an instance of my native callback class to the parent SoundSample object. I was thinking I could pass an instance of the SoundSample class to the SoundCallback object, but it seems like it does not allow me to declare a ref class field in the native class:
SoundCallback.h(9): error C2143: syntax error : missing ';' before '^'
SoundCallback.h(9): error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
SoundCallback.h(9): error C3699: '^' : cannot use this indirection on type 'int'
I looked back at implementing callbacks in native C++ and I could not find a reasonable solution so far. What is the best/easiest way to do this?
Solved it (thanks to Jeremiah Morrill) - the problem is not with any barrier blocking the use of ref classes in basic classes. C4430 means that SoundSample is an unrecognized type, which was hidden by Intellisense - since that seemed to indicate that SoundSample is known.
What needs to be added is a declaration of the SoundSample type and this all starts working fine.
I just added
namespace MyNamespace { ref class SoundSample; }
before the SoundCallback class declaration and then SoundCallback class could declare:
MyNamespace::SoundSample^ sample;
Here's interface that I have declared:
[ServiceContract]
public interface class IShedluer
{
[OperationContract]
array<Object^>^ GetResult(UInt64 taskId);
}
Here's the class that is trying to implement it:
ref class MyShedluer:IShedluer
{
Shedluer ^shedluer;//this is NOT MyShedluer
public:
MyShedluer(void);
array<Object^>^ GetResult(UInt64 taskId)
{
return shedluer->GetResult(taskId);
}
}
When I'm trying to compile this, I'm getting
Error 15 error C3766: 'MyShedluer' must provide an implementation for
the interface method 'cli::array<Type> ^IShedluer::GetResult(unsigned __int64)'
d:\users\menkaur\documents\visual studio 2010\projects\MyProject\
\kernel\MyShedluer.h 78 1 MyProject.Kernel
Why am I getting this?
the correct syntax for implementing an interface is to add virtual:
ref class MyShedluer:IShedluer
{
public:
virtual array<Object^>^ GetResult(UInt64 taskId);
}
Also the compiler tells you this, look at your warnings as well:
warning C4488: 'MyShedluer::GetResult' : requires 'virtual' keyword
to implement the interface method 'IShedluer::GetResult'