我有QML的问题,调用Q_INVOKABLE函数.虽然我将功能标记为Q_INVOKABLE但我遇到了错误
TypeError: Result of expression 'azdownloader.setData' is not a function
TypeError: Result of expression 'azdownloader.perform' is not a function
Run Code Online (Sandbox Code Playgroud)
我有这门课:
typedef QString lyricsDownloaderString;
class lyricsDownloader : public QObject
{
public:
Q_INVOKABLE virtual short perform() = 0;
Q_INVOKABLE inline void setData(const string & a, const string & t); // set artist and track
// some other data
protected:
lyricsDownloader(const string & a, const string & t ) : artist(a), track(t) {}
/*other data*/
};
class AZLyricsDownloader : public lyricsDownloader
{
public: …Run Code Online (Sandbox Code Playgroud) 我正在使用Q_PROPERTY和QML.我的代码是:
using namespace std;
typedef QString lyricsDownloaderString; // this may be either std::string or QString
class lyricsDownloader : public QObject
{
Q_OBJECT
public:
Q_PROPERTY(QString lyrics READ lyrics NOTIFY lyricsChanged)
Q_INVOKABLE virtual short perform() = 0;
inline void setData(const string & a, const string & t); // set artist and track
Q_INVOKABLE inline void setData(const QString & a, const QString & t); // for QStrings
Q_INVOKABLE inline bool anyFieldEmpty(); // check whether everything is filled
inline QString lyrics()
{
return lyrics_qstr; …Run Code Online (Sandbox Code Playgroud) 我想在用户按住 Button 时打开上下文菜单(为了方便起见,我使用 Button)。如果我做
Button
{
text: model.ualabel
MouseArea
{
preventStealing: true
anchors.fill: parent
onPressAndHold: uaContextMenu.open()
}
ContextMenu
{
id: uaContextMenu
MenuLayout
{
MenuItem { /**/ }
}
}
}
Run Code Online (Sandbox Code Playgroud)
然后负责 pressAndHold 的 MouseArea 会窃取所有手势,即使无法单击 Button。我究竟做错了什么?我正在使用 Qt 4.7 并导入QtQuick 1.1和com.nokia.meego 1.0
谢谢
我在文件中有给定的接口规范module.mli。我必须将其实现写入module.ml文件中。
module.mli提供一个抽象类型
type abstract_type
Run Code Online (Sandbox Code Playgroud)
我正在使用 OUnit 来创建测试。我需要在其中使用类型的实现。(例如比较值)一种解决方案是扩展接口以包含测试中使用的附加函数。
但是不修改接口就可以做到这样的事情吗?
是否可以像在webOS上一样从QML中删除ListView中的项目,即在刷入条目后会有"取消"和"删除".
我想用Qt 4.7(所以QtQuick 1.1)
我正在尝试用QML获取记录的数量LocalStorage,它使用的是sqlite.我们考虑一下这个片段:
function f() {
var db = LocalStorage.openDatabaseSync(...)
db.transaction (
function(tx) {
var b = tx.executeSql("SELECT * FROM t")
console.log(b.rows.length)
var c = tx.executeSql("SELECT COUNT(*) FROM t")
console.log(JSON.stringify(c))
}
)
}
Run Code Online (Sandbox Code Playgroud)
输出是:
qml :3 qml:{"rowsAffected":0,"insertId":"","rows":{}}
我输错了SELECT COUNT(*)什么不输出任何东西?
编辑: rows在第二个命令中只显示为空.调用
console.log(JSON.stringify(c.rows.item(0)))
Run Code Online (Sandbox Code Playgroud)
给
qml:{"COUNT(*)":3}
现在有两个问题:
rows显示为空c.rows.item(0)我想在OCaml中声明一个变体类型
type 'a tree = Node of 'a tree * 'a * 'a tree * int | Null
Run Code Online (Sandbox Code Playgroud)
但是这里有很多属性,所以我想标记它们,所以我尝试在这里使用一条记录:
type 'a tree = Node of { left: 'a tree; value: 'a; right:'a tree; height: int | Null
Run Code Online (Sandbox Code Playgroud)
但这会引发语法错误.
使用像记录一样的东西可以让我使用漂亮的语法
match x with
| Node of a -> a.value
| Null -> 0
Run Code Online (Sandbox Code Playgroud)
我该如何声明它不会出现语法错误?
我想打开一个文件描述符仅供阅读
mkfifo my_fifo
exec 3<$my_fifo
Run Code Online (Sandbox Code Playgroud)
这个挂了。
另一方面,当我做
exec 3<>$my_fifo
Run Code Online (Sandbox Code Playgroud)
然后它起作用了。为什么?
我需要检测我的后台进程之一何时退出。因此,我安装了一个陷阱。run_gui并且run_ai1是简单的exec函数。
run_gui & gui_pid=$!
run_ai1 & ai1_pid=$!
trap 'echo foo' SIGCHLD
while true; do
echo "Started the loop"
while true; do
read -u $ai1_outfd line || echo "Nothing read"
if [[ $line ]]; then
: # Handle this
fi
done
while true; do
read -u $gui_outfd line || echo "nothing read"
if [[ $line ]]; then
: # Handle this
fi
done
done
Run Code Online (Sandbox Code Playgroud)
当我关闭 GUI 时,没有任何反应。该echo foo命令仅在我按 ctrl+c 时执行。
为什么我想念SIGCHLD?
execlp与我们一起运行命令
execlp("ps", "ps", NULL);
Run Code Online (Sandbox Code Playgroud)
这里可以看到冗余,因为我们通过了ps两次。此行为在所有exec变体中都是一致的。
为什么 exec 需要这样的冗余?为什么不这样写,以便我们可以简单地
execlp("ps", NULL);
Run Code Online (Sandbox Code Playgroud)