Convert QImage to BitmapHandle
-
I am using "VideoCapX" activeX in my application.
I want to call its method which is as follows,
@
Function SetBitmapOverlay (BitmapHandle As Long, x As Long, y As Long, TransColor As Long, Alpha As Long) As Long
@I have QImage and i want to pass it to this function in first parameter. The problem is i need to convert QImage to BitmapHandle and i dont know how to do it.
I tried to pass reference of QImage itself but then it gives following error,
@
QAxBase: Error calling IDispatch member SetBitmapOverlay: Type mismatch in parameter 0
@
My question is how to convert QImage to bitmap handle ? -
I have got another problem...
As suggested by Andre,this is how i tried,@QPixmap pixmap("CrossHairScaled.bmp");
HBITMAP handle = QtWin::toHBITMAP(pixmap);
ui->videoCapX->dynamicCall("SetBitmapOverlay(HANDLE, long, long, long)", QVariant(handle), QVariant(0), QVariant(0),QVariant(0xFFFFFF));
@And this is the error
@'QVariant::QVariant(void*)' is private
inline QVariant(void *) Q_DECL_EQ_DELETE;
@Dynamic call expects all inputs as QVariant and there is no method in QVariant to convert a void* into QVariant.
So now the question is how to pass void* to dynamic call as QVariant ? -
Hey Andre
I looked into QVariant::fromValue<T>(T value).
But it seems that it will not work here, since HBITMAP is a void *.
Still i tried it like this,
@#include <QPixmap>
#include <QtWin>namespace Ui {
class camera;
}Q_DECLARE_METATYPE(HBITMAP)
class camera : public QMainWindow
{
Q_OBJECTpublic:
explicit camera(QWidget *parent = 0);
~camera();
@This ends in crash. I thing this function is only for structures.
Please correct me if i am going wrong...