qt-quick

How do I show a message box with Qt Quick Controls?

ε祈祈猫儿з 提交于 2019-12-23 06:59:08
问题 What is the equivalent of QMessageBox::information() when one wishes to write a QML application using Qt Quick Controls? 回答1: In Qt 5.2 there is MessageDialog: http://doc.qt.io/qt-5/qml-qtquick-dialogs-messagedialog.html import QtQuick 2.2 import QtQuick.Dialogs 1.1 MessageDialog { id: messageDialog title: "May I have your attention please" text: "It's so cool that you are using Qt Quick." onAccepted: { console.log("And of course you could only agree.") Qt.quit() } Component.onCompleted:

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

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:

Binding Checkbox 'checked' property with a C++ object Q_PROPERTY

回眸只為那壹抹淺笑 提交于 2019-12-21 17:42:05
问题 I'm learning QtQuick and I'm playing with data binding between C++ classes and QML properties. In my C++ object Model, I have two properties : Q_PROPERTY(QString name READ getName WRITE setName NOTIFY nameChanged) Q_PROPERTY(bool status READ getStatus WRITE setStatus NOTIFY statusChanged) And in my .qml file : TextEdit { placeholderText: "Enter your name" text: user.name } Checkbox { checked: user.status } When I change the user name with setName from my C++ code, it is automatically

Applying MVVM pattern in a QtQuick

点点圈 提交于 2019-12-20 13:52:07
问题 How can i apply MVVM pattern in QtQuick applications? Can anybody give me any sample (simple) code? Thanks 回答1: With a C++ ViewModel I know someone has done the same thing with a QML ViewModel and bi-directional binding for the text element for example. Bi-directional binding is done through the binding of the text property to the viewmodel property. Then, add a Binding node to bind the viewmodel property to the text property of the textinput. 来源: https://stackoverflow.com/questions/8533859

Rendering custom opengl in qt5's qtquick 2.0

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-20 12:35:43
问题 I'm looking for a way to render my custom opengl calls inside a qtquick 2.0 item. To give you some context: I have a C++ 3d engine that uses opengl for rendering. The goal is to have it rendering inside a qtquick 2.0 UI. What I found out is that pre qt 5.0 (qtquick 2.0) you would use a QtGlWidget and embed that into the QDeclarativeView. Another way I found would be to use a QtDeclarativeItem and override the void QDeclarativeItem::paint(QPainter *p, const QStyleOptionGraphicsItem *o, QWidget

Does Python go well with QML (Qt-Quick)?

无人久伴 提交于 2019-12-20 08:59:17
问题 I am a beginner in Qt-Quick. I am not aware of Qt which is a basis for QML. And also I'm not familiar with C++ which is again main supported language for both Qt and QML. I'm aware JS can do a lot of logic in QML layer itself. But if we need interactions with OS, then we have to use some base language. As I'm comfortable with Python, I m planning for " QML-JS-Python " combination. So, My questions: For advanced Application and Game development Does Python & Qt-Quick do well hand in hand? Is

ListView in subwindow triggers immediate close, or whilst scrolling

风格不统一 提交于 2019-12-20 04:13:01
问题 I have rather strange scenario whereby if I launch a subwindow that contains a ListView with a moderately complex delegate and enough items to comfortably exceed the visible area, the entire subwindow will immediately close on launch. Reducing the complexity of the delegate will allow the window to open, but then rapidly scrolling the ListView will forcibly close it. This SSCCE triggers the effect on my laptop, but on a more powerful machine it may only do it whilst scrolling (or perhaps the

ReferenceError in qt quick controls tabview

不问归期 提交于 2019-12-19 11:24:15
问题 I have written a QT Quick program use TabView. When I click the botton b1 which is in Tabview, the program should call show_text() and print the text of b1, but it print "ReferenceError: b1 is not defined". Any suggestion will be appreciated, thanks. import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Window 2.1 ApplicationWindow { function show_text() { console.log(b1.text) } TabView { id: tv Tab { id: tab1 Button{ id: b1 text:"b1's text" onClicked: { //console.log(b1.text) show

Qt - How to run a C++ function when QML button is clicked? Using QQmlApplicationEngine

寵の児 提交于 2019-12-19 10:33:26
问题 myclass.h #ifndef MYCLASS_H #define MYCLASS_H #include <QDebug> #include <QObject> class MyClass : public QObject { public: MyClass(); public slots: void buttonClicked(); void buttonClicked(QString &in); }; #endif // MYCLASS_H myclass.cpp #include "myclass.h" MyClass::MyClass() { } void MyClass::buttonClicked() { // Do Something } void MyClass::buttonClicked(QString &in) { qDebug() << in; } main.cpp #include <QApplication> #include <QQmlApplicationEngine> #include <myclass.h> #include