pass two arguments into the c++ api from qml site
when I add & on the api, the app can not recognize the signature
of the function.
.hpp
#ifndef TESTPARAM_HPP
#define TESTPARAM_HPP
#include <QList>
#include <QObject>
#include <QUrl>
{
Q_OBJECT
public:
explicit testParam
(QObject *parent
= 0);
signals:
public slots:
void test(QList<QUrl> &first, QList<QUrl> &second)
{
}
};
#endif // TESTPARAM_HPP
#ifndef TESTPARAM_HPP
#define TESTPARAM_HPP
#include <QList>
#include <QObject>
#include <QUrl>
class testParam : public QObject
{
Q_OBJECT
public:
explicit testParam(QObject *parent = 0);
signals:
public slots:
void test(QList<QUrl> &first, QList<QUrl> &second)
{
}
};
#endif // TESTPARAM_HPP
To copy to clipboard, switch view to plain text mode
.cpp
#include "testParam.hpp"
testParam
::testParam(QObject *parent
) : {
}
#include "testParam.hpp"
testParam::testParam(QObject *parent) :
QObject(parent)
{
}
To copy to clipboard, switch view to plain text mode
main.qml
import QtQuick 2.1
import QtQuick.Dialogs 1.0
import Test 1.0
Rectangle {
width: 100
height: 62
TestParam{
id: testParam
}
FileDialog{
id: fileDialog
//selectFolder: param.selectFolder
selectMultiple: true
nameFilters: [ "Image files (*.bmp *.jpg *.JPEG *.png *.ppm *.tiff *.xbm *.xpm)" ]
onAccepted: {
testParam.test(fileDialog.fileUrls, fileDialog.fileUrls);
}
}
MouseArea{
anchors.fill: parent
onClicked: {
fileDialog.open();
}
}
}
import QtQuick 2.1
import QtQuick.Dialogs 1.0
import Test 1.0
Rectangle {
width: 100
height: 62
TestParam{
id: testParam
}
FileDialog{
id: fileDialog
//selectFolder: param.selectFolder
selectMultiple: true
nameFilters: [ "Image files (*.bmp *.jpg *.JPEG *.png *.ppm *.tiff *.xbm *.xpm)" ]
onAccepted: {
testParam.test(fileDialog.fileUrls, fileDialog.fileUrls);
}
}
MouseArea{
anchors.fill: parent
onClicked: {
fileDialog.open();
}
}
}
To copy to clipboard, switch view to plain text mode
error message
Error: Unknown method parameter type: QList<QUrl>&
They are fine if
1 : strip the &
2 : reduce the parameters of “test†to a single parameter, that way you can preserve the &
Anyway to pass the parameters as reference into the “test†with two parameters?
Bookmarks