delphi如何调用C++的对象(100分)

  • 主题发起人 linuxping
  • 开始时间
L

linuxping

Unregistered / Unconfirmed
GUEST, unregistred user!
比如,自己定义了C++类:
#ifndef PROXYWIDGET_H
#define PROXYWIDGET_H
#include <QGraphicsProxyWidget.h>
#include <QTimeLine.h>
class ProxyWidget : public QGraphicsProxyWidget
{
Q_OBJECT
public:
ProxyWidget(QGraphicsItem *parent, Qt::WindowFlags wFlags=0);
virtual ~ProxyWidget();
QRectF boundingRect() const;
void paintWindowFrame(QPainter *painter, const QStyleOptionGraphicsItem *option,
QWidget *widget);
protected:
void hoverEnterEvent(QGraphicsSceneHoverEvent *event);
void hoverLeaveEvent(QGraphicsSceneHoverEvent *event);
bool sceneEventFilter(QGraphicsItem *watched, QEvent *event);
QVariant itemChange(GraphicsItemChange change, const QVariant &amp;value);
private slots:
void updateStep(qreal step);
void stateChanged(QTimeLine::state);
void zoomIn();
void zoomOut();
private:
QTimeLine *timeLine;
bool popupShown;
};
#endif // PROXYWIDGET_H
然后写一个dll:
ProxyWidget getProxyWidget (QGraphicsItem *parent{
return new ProxyWidget (parent);
}
delphi如何调用这个函数,如何获得这个对象,如何使用这个对象?
 
A

apiao

Unregistered / Unconfirmed
GUEST, unregistred user!
很遗憾的告诉你,不能直接引用
因为这是c++的特有的,虽然扩展名是dll
但是其像delphi的bpl一样,只能在c++环境下引用
 
L

linuxping

Unregistered / Unconfirmed
GUEST, unregistred user!
不是吧
如此残酷!!!!!!
 
T

tseug

Unregistered / Unconfirmed
GUEST, unregistred user!
参考
http://desktop.chinaitlab.com/Delphi/717942.html
 
C

creation-zy

Unregistered / Unconfirmed
GUEST, unregistred user!
tseug兄给的文章写的很清楚了——要让Delphi调用C++的类,这个类的方法必须是纯虚函
数(支持虚函数的VMT机制,Delphi和C++是一致的),否则免谈(或者做成COM :) )。
 
L

linuxping

Unregistered / Unconfirmed
GUEST, unregistred user!
顶部