标签: qtdeclarative

写入全局属性QML无效

我有这个信号

class SystemUICfgScanner 
{
    /*code here*/
signals:
    void error(QString desc);
    /*more code*/
};
Run Code Online (Sandbox Code Playgroud)

在QML中,我使用InfoBanner:

InfoBanner
{
    property string infodetails: ""
    id: systemuicfgErrorBanner
    text: "Error: " + infodetails
    Connections
    {
        target: cfgScanner
        onError: infodetails = desc
    }
}
Run Code Online (Sandbox Code Playgroud)

当发出错误(QString)信号时,我收到此错误

Invalid write to global property "infodetails"
Run Code Online (Sandbox Code Playgroud)

我究竟做错了什么?

提前致谢

qt properties qt4 qml qtdeclarative

13
推荐指数
1
解决办法
7566
查看次数

OpenGL渲染到QML项目

我有一个QML文件,其中包含QML项目的布局,现在我希望其中一个项目是QGLWidget.即我想渲染到特定的QML项目.

有人知道怎么做吗?

qt qglwidget qml qtdeclarative

6
推荐指数
1
解决办法
4060
查看次数

PySide:将数据从QML传递到Python

我正在尝试将数据从QML发送到Python,但出现错误。

test.py:

#!/usr/bin/env python

import sys
from PySide import QtCore, QtGui, QtDeclarative

class Test( QtCore.QObject ):
    def __init__( self ):
        QtCore.QObject.__init__(self)

    @QtCore.Slot()
    def printText(self,text):
        print text

class MainWindow( QtDeclarative.QDeclarativeView ):
    def __init__( self, parent=None ):
        super( MainWindow, self ).__init__( parent )
        self.setWindowTitle( "Test" )
        self.setSource( QtCore.QUrl.fromLocalFile( './test.qml' ) )
        self.setResizeMode( QtDeclarative.QDeclarativeView.SizeRootObjectToView )

app = QtGui.QApplication( sys.argv )
window = MainWindow()
context = window.rootContext()
context.setContextProperty("testModel",Test())
window.show()
sys.exit( app.exec_() )
Run Code Online (Sandbox Code Playgroud)

test.qml:

import QtQuick 1.0

Rectangle {
    width: 200
    height: 200
    color: "white" …
Run Code Online (Sandbox Code Playgroud)

python qt pyside qml qtdeclarative

5
推荐指数
1
解决办法
1612
查看次数

QML-图像不会在应用程序的已部署版本中加载

我写了一个Qt / QML应用程序,在编译期间一切正常,并且在我自己的系统上运行。但是,当我将此软件移至另一台计算机时,没有图片加载。例如,这是我的背景图片:

    Image{
    id:background;
    source:"qrc:/qml/MobnaPC/images/back.jpg"
}
Run Code Online (Sandbox Code Playgroud)

当我在系统(开发环境系统)中运行可执行文件(在发布模式下创建)时加载此图像,但是当我将此文件及其关联的dll移动到另一个系统(未安装Qt)时,背景图像不加载。
我还尝试了相对寻址而不是资源系统。但是问题仍然存在。我该如何解决这种奇怪的行为?

qt qml qtdeclarative

5
推荐指数
1
解决办法
1674
查看次数

Q_PROPERTY未显示

我正在使用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)

qt qt4 qml qtdeclarative

4
推荐指数
1
解决办法
803
查看次数

标签 统计

qml ×5

qt ×5

qtdeclarative ×5

qt4 ×2

properties ×1

pyside ×1

python ×1

qglwidget ×1