qml

QML做渐变色文字动画

拥有回忆 提交于 2020-01-28 05:01:10
Item { id: container width:200 height:200 Rectangle { id: gradientRect; width:80 height: 80 gradient: Gradient { GradientStop { position: 0; color: "red" } GradientStop { position: 1; color: "steelblue" } } visible: false layer.enabled: true; layer.smooth: true } Text { id: text anchors.centerIn: parent color: "pink" text: "Hello world!" font.pixelSize: 32 layer.samplerName: "maskSource" layer.enabled: true layer.effect: ShaderEffect { property var colorSource: gradientRect; fragmentShader: " uniform lowp sampler2D colorSource; uniform lowp sampler2D maskSource; uniform lowp float qt_Opacity;

Long TabBar - adding a size and position indicator to reflect the presence of off-screen tabs

蹲街弑〆低调 提交于 2020-01-26 04:15:28
问题 I have a tab bar with a stacklayout like the following: Rectangle { id: rect height: 190 anchors.right: parent.right anchors.left: parent.left color: "transparent" anchors.top: uniqueHandleText.bottom anchors.topMargin: 100 TabBar { id: frame anchors.right: parent.right anchors.left: parent.left background: Rectangle { color: "#737373" } x: -hbar.position * width Repeater { model: wizard.categories TabButton { id: tabData property bool selected: false text: modelData.name width: 200 font

Qt show application, if currently running

霸气de小男生 提交于 2020-01-26 03:41:07
问题 I'm creating a single instance app, which is minimised to system tray, I want to show the currently running instance, then quit the new one. How can I create this functionality? main.cpp #include <QApplication> #include <QQmlApplicationEngine> #include <QIcon> #include <QQuickWidget> #include <QSystemTrayIcon> #include <QQmlContext> #include <QQmlEngine> #include <QSystemSemaphore> #include <QSharedMemory> // Declare a user-defined data type to work with an icon in QML Q_DECLARE_METATYPE

Warning when connecting c++ signal to qml slot

半腔热情 提交于 2020-01-25 15:50:05
问题 I connect a c++ signal to qml function in qt4.8.4. It's working fine but makes warning in application output as below: Object::connect: No such slot QDeclarativeItem_QML_9::onValue_changed(double) Object::connect: (sender name: 'MyWidget') I have defined qml slot like this : import QtQuick 1.0 Item { id: root property real value : 0 Connections { target: controllerObject onValue_changed : { root.value = value } } } And this is my c++ Signal and how it is connected to qml slot : ui->view-

Qt5 - QML: Button does not show up after triggered

家住魔仙堡 提交于 2020-01-25 11:10:37
问题 I am writing a project that is using Qt5-QML . In order to shrink the problem I prepared a small example that replicates the problem. 1) I have an application on a Page1 . That carries a Button as shown in the below print screen below: 2) After the user pushes the button goes on Page2 shown below which carries different Buttons . Let's say Button A it is the user's choice: 3) The final screen represented by Page1 is the correct choice, which is the the button selected The problem I have is

Passing a pointer to QML string property to C++

巧了我就是萌 提交于 2020-01-25 08:42:34
问题 How do you pass a pointer to string property from QML to C++? When I attempted to do it the obvious way, I got this error: qrc:/NewAccount.qml:236: Error: Unknown method parameter type: QString* Which means, QML engine can't convert new_account.error_string property to C++ when calling save_account (Q_INVOKABLE) method This is my code in QML: import myproject.aewm.ethkey 1.0 import myproject.aewm.walletaccount 1.0 ... id: new_account property EthKey key: EthKey{} property WalletAccount

How to disable rendering in QML WebView?

╄→гoц情女王★ 提交于 2020-01-25 06:01:40
问题 I am currently building an application that makes use of QML WebView ( import QtWebKit 3.0 ). The users need to resize the WebView very often (I am using a QML SplitView ), however this leads to the UI to lag extremely whenever the app window is resized. Is there any way to prevent this? 回答1: Instead of changing the width and height properties change scale property of the WebView . At beginning of the resize save initial values of width and height . On resize don't change width and height .

Qt5-QML: automatic authentication username and password with on a third party device

喜夏-厌秋 提交于 2020-01-25 04:14:26
问题 After understanding how to integrate JavaScript functions into Qt-QML I am now trying to apply what I have learned in my previous post to a small real world example in my lab. I am trying to access to my robots via wi-fi using using a third party device present in my lab. I have a log-in form provided by the device as shown in the print screen given below. The address is, for example, https://123.456.789.123:7878 (which I made up but it is for understanding the idea): After navigating the

Can't display data from QSqlQueryModel in a QML TableView

梦想与她 提交于 2020-01-25 04:01:07
问题 I'm trying to display data from a MySQL database in a table with the help of TableView component of QML. Initially I tried making a QSqlQueryModel object from a QSqlQuery object and pass it to QML context as a property. But I came to know from Qt documentation that I must implement roleNames() to supply column to role mapping to TableView , so I subclassed QSqlQueryModel like so import sys from PyQt5.QtCore import QUrl, Qt from PyQt5.QtGui import QGuiApplication from PyQt5.QtQuick import

linux系统平台,使用QML结合C/C++实现图片浏览功能

偶尔善良 提交于 2020-01-25 02:25:59
一、原理: 使用QML的Image控件显示图片,通过修改Image控件“source”属性,可以让Image控件显示不同的图片,“source”属性指定图片的全路径(图片路径及图片的名字),在C++代码中可以实现图片全路径的更换,通过QML和C++的交互,QML可以取得新的图片的路径,达到切换图片的目的。 二、主要实现功能: 上一张/下一张图片显示、图片的放大/缩小、图片的左旋转/右旋转、幻灯片播放/暂停、返回上一层画面和返回主画面等功能。 三、实现方法/步骤: 1、在QML文件中描画各种按钮的位置及图片的显示区域。 2、用linux的“find”命令建立播放列表,生成名为“pic.lst”的文件,该文件保存指定路径下的所有符合指定扩展名的全部图片,每一行保存一个图片文件的全路径,在C++代码中实现。 3、使用C/C++语言的QFile对文件“pic.lst”进行操作,可以实现读取其中一行的功能,即取出一个图片的全路径 4、“pic.lst”文件中每一行保存一个图片的全路径,使用C/C++语言,通过不同行的行号,来取得不同图片的全路径,实现上一个/下一个图片取得的功能。 5、通过设置Image控件的“scale”属性,实现图片的放大和缩小功能。 例如: imageShow.scale = 1.0; /* 图片原始尺寸 */ imageShow.scale += 0.1; /*