qtquickcontrols

How can I inject JavaScript file into a WebEngineView page?

孤人 提交于 2019-12-10 18:16:20
问题 I'm adding a script tag to a web page once it's fully loaded in a WebEngineView , but it's silently failing somehow. I inject the script by invoking webview.runJavaScript with this code: var s = document.createElement('script'); s.src = "qrc:/jquery-2.1.4.min.js"; document.body.appendChild(s); That's perfectly standard and to a certain extent it works as expected, i.e., if I view the html source of the page, the script tag has indeed been appended to the body. The problem is that the script

QML window resize/move flicker

坚强是说给别人听的谎言 提交于 2019-12-06 18:18:22
问题 I'm developing a simple QML application right now and I noticed that resizing and moving a QML window generates an ugly flicker compared to a QtWidgets window, for instance. So I created 2 test applications to show the difference: QWidgets: QML: As you can see the QML version of the application flickers pretty ugly while the QtWidgets one is clean. Now this gets pretty ugly when your UI grows in complexity. Do you have any knowledge about this? Is this a bug? Is there any fix/workaround for

QML TreeView not updating at runtime after adding new data to the model

放肆的年华 提交于 2019-12-06 13:53:48
问题 I have a QML TreeView that gets data through a QStandardItemModel . When the application is running, I press a button which adds a new entry. I know the data is changing, but the QML TreeView is not updating. I've also tried beginResetModel() and endResetModel() . The data is correctly displayed in the TreeView upon loading the application, but the TreeView does not change when modifying the data in the model. treeviewmodel.cpp #include <QDebug> #include <QStandardItemModel> #include

Creating a scalable, glossy/shiny button with Qt Quick

穿精又带淫゛_ 提交于 2019-12-06 01:59:39
问题 I'd like to create the glossy button below with Qt Quick (preferably with pure QML, no C++): It needs to be scalable, so I can't use PNGs, etc. My code so far: import QtQuick 2.3 import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 ApplicationWindow { id: window color: "#cccccc" width: 200 height: 200 Button { id: button width: Math.min(window.width, window.height) - 20 height: width * 0.3 anchors.centerIn: parent text: "Button" style: ButtonStyle { background: Rectangle { gradient:

QML TreeView not updating at runtime after adding new data to the model

左心房为你撑大大i 提交于 2019-12-04 18:22:24
I have a QML TreeView that gets data through a QStandardItemModel . When the application is running, I press a button which adds a new entry. I know the data is changing, but the QML TreeView is not updating. I've also tried beginResetModel() and endResetModel() . The data is correctly displayed in the TreeView upon loading the application, but the TreeView does not change when modifying the data in the model. treeviewmodel.cpp #include <QDebug> #include <QStandardItemModel> #include "treeviewmodel.h" TreeViewModel::TreeViewModel(QObject *parent) : QStandardItemModel(parent) { m

How to take Screenshot of QML application without QQuickView

廉价感情. 提交于 2019-12-03 14:01:41
I want to grab screen of my QML application. But my root QML object is ApplicationWindow , so I can't use QQuickView to show it. Instead I have to use QQmlApplicationEngine . I know how to take screenshot with QQuickView ( QQuickWindow::grabWindow ), but don't know how to take it with QQmlApplicationEngine . My main file: int main(int argc, char *argv[]) { QApplication app(argc, argv); ApplicationData appData; QQmlApplicationEngine engine; engine.load(QUrl("qrc:///main.qml")); return app.exec(); } main.qml : import QtQuick 2.1 import QtQuick.Controls 1.1 import QtQuick.Window 2.1

how to sort QML TableView in QtQuick 2?

拟墨画扇 提交于 2019-12-03 09:14:00
I want to implement a sortable TableView with custom roles with Qt 5.1. But I don't know what to do more to make it sorted when user clicked on header. in my Qt .pro file, I added: !android: !ios: !blackberry: qtHaveModule(widgets): QT += widgets in main.cpp, I used QtWidgets/QApplication as global app instance, and used qmlRegisterType for my new model class(see below): qmlRegisterType<PositionModel>("MyDataModule", 1, 0, "PositionModel"); PositionModel is declared following: class PositionModel : public QAbstractTableModel { Q_OBJECT public: enum PositionRoles { CustomRol1 = Qt::UserRole + 1

Resolve resource ambiguity in QML imports

守給你的承諾、 提交于 2019-12-02 06:12:45
问题 I need to use both QtLabs and QtQuickControls. Both have the Button type but I need to use the one in QuickControls. The QML file is picking the button in labs. How do I force it to use the one in QuickControls? import QtQuick 2.6 import QtQuick.Controls 1.5 //This is what I need the QML file to pick button from import QtQuick.Controls.Styles 1.4 import QtGraphicalEffects 1.0 import QtQuick.Dialogs 1.2 import QtMultimedia 5.6 import Qt.labs.controls 1.0 //This is where it is picking Button

How to package custom controls in QML?

杀马特。学长 韩版系。学妹 提交于 2019-12-02 04:18:09
I would like to create a library of QML custom controls that I would provide to my customers. At the same time I don't want my customers to "reverse-engineer" my controls by peeking into the QML source code. What are my best options to avoid this? The ideal scenario would that I provide my controls as a compiled library that they could import in their own projects. My target platforms are iOS and Android. How can I create the package for custom QML controls? These controls should not be packaged in the source code form to prevent reverse-engineering. The question implies that the author has

ReferenceError in qt quick controls tabview

半腔热情 提交于 2019-12-01 12:27:40
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_text() } } } } } Pass the object as a parameter import QtQuick 2.2 import QtQuick.Controls 1.1 import