qml

Adding Items to a layout of a custom component

天涯浪子 提交于 2019-12-22 08:36:22
问题 I have a custom Footer Component which I would like to reuse in different place in my QML App: Rectangle { color: "gold" height: 50 anchors { bottom: parent.bottom left: parent.left right: parent.right } RowLayout { anchors.fill: parent anchors.margins: 10 Button { text: "quit" } } } The use of this is easy: Window { visible: true Footer { } } But now I would like to add a "ButtonA" to the RowLayout of my Footer in one view and a "ButtonB" in another view. How can I achieve that? 回答1: See

Transparency of QDeclarativeView containing QML on top of a QWidget playing a video (using either phonon or libvlc)

牧云@^-^@ 提交于 2019-12-22 08:18:27
问题 I am currently developing a video player. The GUI as the topmost layer is written in QML. It should be transparent to lower layers. It contains control elements, some Lists etc., It's displayed using a QDeclarativeView . Description QDeclarativeView *upperLayer = new QDeclarativeView(this); upperLayer->setSource(QUrl("/home/projects/QtVideo/qml/videoControl.qml")); upperLayer->setStyleSheet(QString("background: transparent"); upperLayer->setResizeMode(QDeclarativeView::SizeRootObjectToView);

Properly reloading a QQmlApplicationEngine

☆樱花仙子☆ 提交于 2019-12-22 08:08:39
问题 I have a QML-based app that loads a main.qml file from the file system like this: myEngine->load("main.qml"); This works fine, but I'd like to "reload" the engine in case the main.qml was replaced with a newer version. What I tried so far was calling load() again, assuming that the engine will automatically reset itself like in other Qt classes. Unfortunately this is not the case. If I call the method again, another window will appear with the contents of the updated qml file, while the

How to connect signals from singleton object defined in C++ code to QML component?

℡╲_俬逩灬. 提交于 2019-12-22 07:50:43
问题 My main objective is to receive signals from singleton objects while defining QML component in *.qml file. Let's say I defined a singleton object in C++ code like this: class MySingleton : public QObject { Q_OBJECT Q_PROPERTY(QString value READ value WRITE setValue NOTIFY valueChanged) typedef QObject Base; public: static MySingleton* instance(); const QString& value() const; void setValue(const QString& value); signals: void valueChanged(); private: MySingleton(QObject* parent = nullptr);

QML: Using cpp signal in QML always results in “Cannot assign to non-existent property”

走远了吗. 提交于 2019-12-22 06:48:12
问题 I just want to connect a cpp signal to a qml slot and tried different ways, but it always results in the same QML-Error at runtime: Cannot assign to non-existent property "onProcessed" ! Why? This is my Cpp Object: #include <QObject> class ImageProcessor : public QObject { Q_OBJECT public: explicit ImageProcessor(QObject *parent = 0); signals: void Processed(const QString str); public slots: void processImage(const QString& image); }; ImageProcessor::ImageProcessor(QObject *parent) : QObject

How to pass enum class to QML?

Deadly 提交于 2019-12-22 06:24:31
问题 I am on learning to QML with Qt and get some trouble with passing enum class to qml . When I use signal with int parameters - it's all right and code work perfectly. But, and here the trouble , if I use signal with some enum class parameters I have undefined values in qml signal handler. I tried to register enum class through qmlRegisterType but it's not working. I will be grateful for the help. Here the code: Some Helper class class Helper : public QObject { Q_OBJECT Q_ENUMS(Requester) Q

Comparison of two approaches to rendering raw OpenGL into a QML UI in Qt

帅比萌擦擦* 提交于 2019-12-22 05:33:33
问题 According to this article, there are two main methods for rendering raw OpenGL into an application whose UI is otherwise managed by QtQuick's scene graph. In short, they are (according to my understanding): Calling raw OpenGL methods in hand-written code that is hooked into the scene graph's render loop through some APIs exposed by QtQuick. Rendering the raw OpenGL portion of your scene to a QQuickFramebufferObject, which is treated like a component in the scene graph and itself rendered as

How to bind to a signal from a delegate component within a ListView in QML

允我心安 提交于 2019-12-22 04:55:26
问题 Let's say I have a ListView of clickable delegate components (or GridView or Repeater ). These delegate components need to emit a signal along with custom data when triggered that can be picked up by the parent of the ListView . How can this signal binding be achieved? e.g. The following code is my attempt but I don't know how to bind the trigger signal of the delegate component to the componentTriggered signal in the root item? Item { id: root anchors.fill: parent signal componentTriggered

FileDialog in QTQuick (QML): Save file under given name

社会主义新天地 提交于 2019-12-22 04:29:12
问题 We're building a Qt Quick app, that must be able to save a file under a given name . In the FileDialog component you can only set a directory. This is not very user-friendly, since you don't want to type in a filename by hand every time you download a file. So far we tried different things FileDialog from QtQuick.Dialogs: filename cannot be set Native dialog via QPlatformFileDialogHelper (naughty private c++ hack): filename cannot be set on Linux (Gnome) Native dialog via static QFileDialog:

QML screen orientation lock

时光怂恿深爱的人放手 提交于 2019-12-22 04:27:14
问题 I need to lock the screen to a specific orientation for an android app that I'm making. is there a way to do that in QML? Google didn't get me any answers. I am using Qt 5.2. 回答1: You can basically use the Screen.orientation property for reading only. See the following example for details: http://qt-project.org/doc/qt-5/qtquick-window-screeninfo-qml.html The proper way as of today is to use the Android manifest file for this as done by the Qt Android developer at Digia for his QtHangMan game