QML 中 QString::arg() 的等价物是什么 [英] What is the equivalence for QString::arg() in QML

查看:26
本文介绍了QML 中 QString::arg() 的等价物是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在 QML 中创建一个包含一些参数的字符串?Qt中的一些类似的东西:

I'm wondering How I can have a string in QML that will be occupied with some arguments? Some thing like this in Qt:

QString str("%1 %2");
str = str.arg("Number").arg(12);//str = "Number 12"

推荐答案

在QML环境中,arg()函数已经添加到字符串原型中,所以基本上可以像C++一样在QML中使用string.arg().

In QML environment, the arg() function already added to the string prototype, so basically you can use the string.arg() in QML just like C++.

关于此的文档较少,但我确信它适用于 Qt 4.7 + QtQuick 1.1

There is less documentation about this, but I'm sure it works in Qt 4.7 + QtQuick 1.1

查看 Qt 5 文档:http:///qt-project.org/doc/qt-5.0/qtqml/qml-string.html

Take at look at the Qt 5 doc : http://qt-project.org/doc/qt-5.0/qtqml/qml-string.html

这篇关于QML 中 QString::arg() 的等价物是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆