我正在使用带有 c++ 和 Qt 的脚本语言 ChaiScript。我已经定义了这样的功能:
void ChaiPainter::drawRectangle(QPainter *painter, int x, int y, int height, int width)
{
painter.drawRect(x, y, width, height);
}
在应用程序绘画事件中:
void MainWindow::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
chaiPainter->mChai.add(chaiscript::var(&painter), "painter");
chaiPainter->mChai.add(chaiscript::fun(&ChaiPainter::drawRectangle), "drawRect");
chaiPainter->mChai("drawRect(painter, 5, 5, 100, 100)");
}
错误是:
'chaiscript::Eval_Error' what(): Error: "No matching function to dispatch to with function 'drawRect'" 在 (1, 1) 评估期间
我做错了什么?