我想从 exprtk 调用一个类的函数。( http://www.partow.net/programming/exprtk/ )
我想用symbol_table.add_function 用这个工具包注册一个函数。因此,需要从该工具包提供的 ifunction 派生我的类:
template <typename T>
struct foo : public exprtk::ifunction<T>
{
foo() : exprtk::ifunction<T>(0)
{}
T operator()()
{
// here I want to access data from a class which owns this struct
}
};
Run Code Online (Sandbox Code Playgroud)
是否有可能以某种方式包含这个结构,一个类可以访问它,并且这个结构的 operator() 可以访问类中的数据?一种可能性是将该类的指针传递给结构的构造函数。有没有更好的办法?
我想从 linux shell 调用 qml-script 并将文本作为参数传递,例如
./message.qml "hello this is a message"
Run Code Online (Sandbox Code Playgroud)
或者
/usr/bin/qt5/qml ./message.qml "hello this is a message"
Run Code Online (Sandbox Code Playgroud)
qml 脚本应显示该文本。
下面的示例 qml 脚本有效,但显示的文本(“hello”)当然是静态的。是否可以在 qml 中查询命令行参数?
#!/usr/bin/qt5/qml
import QtQuick 2.2
Rectangle {
width: 1024
height: 600
Text {
anchors.centerIn: parent
text: "Hello" // here I want to have a text which is set in the call
}
MouseArea {
anchors.fill: parent
onClicked: {
Qt.quit()
}
}
}
Run Code Online (Sandbox Code Playgroud)