qml

Proper way to implement an editable QAbstractListModel subclass for QML ListView

早过忘川 提交于 2019-12-23 03:04:11
问题 I am trying to make an editable model for a ListView in QML, using QAbstractListModel. Since it is stated in the Qt Documentation, I tried implementing setData() for my model, but I am facing several issues. The setData() member function is defined as such: bool setData(const QModelIndex &index, const QVariant &value, int role) However, in my ListView delegate I have something like this: MouseArea { anchors.fill: parent onClicked: elementClicked(index) } Is there a proper way to cast the

Exposing qml Object to Website/Javascript using QWebChannel

夙愿已清 提交于 2019-12-23 03:01:15
问题 I would like to display a custom input device on a touchscreen as soon as a html input field gets focused within the displaying QWebEngineView. Therefore I tried to expose the input device object via QWebChannel to the client side Javascipt, which could then invoke the show method of the input device as soon as an input field gets focused. However, currently I get one of the following two errors: Uncaught TypeError: Cannot read property 'send' of undefined at line 60 Uncaught ReferenceError:

Exposing qml Object to Website/Javascript using QWebChannel

耗尽温柔 提交于 2019-12-23 03:01:13
问题 I would like to display a custom input device on a touchscreen as soon as a html input field gets focused within the displaying QWebEngineView. Therefore I tried to expose the input device object via QWebChannel to the client side Javascipt, which could then invoke the show method of the input device as soon as an input field gets focused. However, currently I get one of the following two errors: Uncaught TypeError: Cannot read property 'send' of undefined at line 60 Uncaught ReferenceError:

Qt invoking qml function with custom QObject type

和自甴很熟 提交于 2019-12-23 02:52:24
问题 I want to invoke a qml method from c++ passing as a parameter a custom type. This is my custom type (*Note that all the code I post is not exactly what i'm using, i've extracted the relevant parts, so if you try to compile it is possible that some changes have to be made) Custom.h class Custom : public QObject { Q_OBJECT Q_PROPERTY(QString ssid READ getSSID WRITE setSSID) public: Q_INVOKABLE const QString& getSSID() { return m_ssid; } Q_INVOKABLE void setSSID(const QString& ssid) { m_ssid =

QQuickWindow::grabWindow: scene graph already in use

坚强是说给别人听的谎言 提交于 2019-12-23 02:38:10
问题 I tried the code shown here: How to take ScreenShot Qt/QML On execution I am getting the error written in the title. My main.cpp is: #include <QGuiApplication> #include <QQmlApplicationEngine> #include <QQuickWindow> #include <QImage> #include <QDebug> #include "screenshot.h" #include <QQuickView> #include <QQmlContext> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); const char* drigUi = "DrigUI"; qmlRegisterType <screenCapture> (drigUi, 1, 0, "ScreenShot");

StackView alternative in QML

匆匆过客 提交于 2019-12-23 02:34:40
问题 I was using till now a StackView in QML to go from one screen to the other. But I figured out it is also possible to just create different items that would be set to visible or not visible to update the screen with a new view. I could have for example a header, a main item (Item1) set to visible and a footer. I could then set Item1 to not visible and Item2 to visible. I was wondering what is the advantage/disadvantage of each solution? (StackView VS views visible/invisible) 回答1: As @ddriver

Qml: Adding content dynamically to a SequentialAnimation

两盒软妹~` 提交于 2019-12-23 01:51:52
问题 I have an Qml component with a SequentialAnimation containing a static sequence of PropertyAction components: SequentialAnimation { id: anim running: true PropertyAction { target: icon; property: "iconid"; value: propStore.anim1 } PropertyAction { target: icon; property: "iconid"; value: propStore.anim2 } PropertyAction { target: icon; property: "iconid"; value: propStore.anim3 } } This accomplishes that a specific icon is animated. However now I'd like to make it a little bit dynamic by

Qt Quick2 window can't be transparent without aero

。_饼干妹妹 提交于 2019-12-23 01:36:07
问题 I'm using Qt 5.7 on Windows 7. I can make my QWindow have opacity, but it can't be transparent. // window1.qml Window { width: 640 height: 480 color: "transparent" } // no transparent, black background // window2.qml Window { width: 640 height: 480 color: "transparent" opacity: 0.5 } // black but 50% opacity background But if I enable aero, then it would be transparent without any problem. I've read a lot of articles about it. but I couldn't find correct answer. https://stackoverflow.com/a

Is it possible to transmit pointer to model from C++ to Qt Quick TableView?

不打扰是莪最后的温柔 提交于 2019-12-23 01:35:06
问题 I have class with QSqlDatabase and with pointer to QSqlTableModel in one class. I use pointer to QSqlTableModel, because initialization of database is going on in constructor and after that I create QSqlTableModel using this database (also in constructor but in heap already). This class is registered type in qml and so I create it in QML. How is it better to point out TableView to the QSqlTableModel pointer of this class? If it is possible. 回答1: It is not entirely clear what you're asking. I

Custom TextEdit, how to hide TextInput when it goes wide

拟墨画扇 提交于 2019-12-23 01:12:48
问题 I've trying to create custom text field using TextInput element (I need it to use validator and custom style). But I can't hide part of TextInput content expanding (see image). I have similar problem with other elements, while it have root item (container) what contains other items, childrens can be seen if they are placed out of container coordinates. How can I make childrens parts hidden if they're out of root container? There is the code, but it's actually just template, I've tried to uze