qml

Qml: how to make text or label selectable?

Deadly 提交于 2021-01-26 21:39:53
问题 Let's say I have text component: Text { text: "Hello" wrapMode: Text.WordWrap } How to make it selectable? 回答1: That is a bug reported: QTBUG-14077, and the workaround is to use TextEdit in read-only mode: TextEdit { text: "Hello" readOnly: true wrapMode: Text.WordWrap selectByMouse: true } 来源: https://stackoverflow.com/questions/49784099/qml-how-to-make-text-or-label-selectable

Qml: how to make text or label selectable?

痴心易碎 提交于 2021-01-26 21:37:21
问题 Let's say I have text component: Text { text: "Hello" wrapMode: Text.WordWrap } How to make it selectable? 回答1: That is a bug reported: QTBUG-14077, and the workaround is to use TextEdit in read-only mode: TextEdit { text: "Hello" readOnly: true wrapMode: Text.WordWrap selectByMouse: true } 来源: https://stackoverflow.com/questions/49784099/qml-how-to-make-text-or-label-selectable

How to expose a C++ Model to QML

余生长醉 提交于 2021-01-20 19:51:41
问题 I'm writing a QML+Qt application . I defined a class like this : class MainClass : public QObject { Q_OBJECT public: rosterItemModel m_rosterItemModel; . . . } rosterItemModel model is a class derived from QAbstractListModel. I exposed MainClass to qml part using this function : qmlRegisterType<MainClass>("CPPIntegrate", 1, 0, "MainClass"); Now I want to assign this model(m_rosterItemModel) from MainClass to model property of a ListView in QML. I tried the following ways but none of them were

How qml call static method from c++

孤街浪徒 提交于 2021-01-19 22:49:44
问题 What I done: validator.h: class UTILSSHARED_EXPORT Validator: public QObject { Q_OBJECT public: Validator(QObject *parent = 0); ~Validator(); Q_INVOKABLE static bool validateMobile(const QString target); }; main.cpp: qmlRegisterUncreatableType<Validator>("CT.Utils", 1, 0, "ValidatorKit", "It just a kit"); qml: import CT.Utils 1.0 ValidatorKit.validateMobile("112344") But unfortunately, I got an error that said: TypeError: Property 'validateMobile' of object [object Object] is not a function

How qml call static method from c++

烂漫一生 提交于 2021-01-19 22:47:55
问题 What I done: validator.h: class UTILSSHARED_EXPORT Validator: public QObject { Q_OBJECT public: Validator(QObject *parent = 0); ~Validator(); Q_INVOKABLE static bool validateMobile(const QString target); }; main.cpp: qmlRegisterUncreatableType<Validator>("CT.Utils", 1, 0, "ValidatorKit", "It just a kit"); qml: import CT.Utils 1.0 ValidatorKit.validateMobile("112344") But unfortunately, I got an error that said: TypeError: Property 'validateMobile' of object [object Object] is not a function

How qml call static method from c++

荒凉一梦 提交于 2021-01-19 22:46:20
问题 What I done: validator.h: class UTILSSHARED_EXPORT Validator: public QObject { Q_OBJECT public: Validator(QObject *parent = 0); ~Validator(); Q_INVOKABLE static bool validateMobile(const QString target); }; main.cpp: qmlRegisterUncreatableType<Validator>("CT.Utils", 1, 0, "ValidatorKit", "It just a kit"); qml: import CT.Utils 1.0 ValidatorKit.validateMobile("112344") But unfortunately, I got an error that said: TypeError: Property 'validateMobile' of object [object Object] is not a function

How to get a blurred translucent QML Window (similar to Fluent Design guidelines) on Windows 10?

不羁的心 提交于 2021-01-18 06:47:34
问题 I would like to get a semi-transparent blurred window in QML on Windows 10 similar to the Fluent Design guidelines (example). I know you can make a transparent window: Window{ visible: true color: "transparent" } but this doesn't achieve the blur effect I am looking at. I am also aware that one can blur elements inside the windows using QtGraphicalEffects like FastBlur but I would like to blur the entire window itself. Is there a way to achieve this? I have also tried using the QtWinExtras

How to call qt keyPressEvent(QKeyEvent *event) from qml Keys.onPressed

别说谁变了你拦得住时间么 提交于 2021-01-04 05:58:46
问题 I have a qml Window with an Item which has Keys.onPressed { } And I have a c++ class which has protected: void keyPressEvent(QKeyEvent *event); What needs to go inside the Keys.onPressed? I have tried myclass.keyPressEvent(event) and I have tried a public Q_INVOKABLE function (handleKeyPress) in my c++ class with parameter (QKeyEvent * event) from which I wanted to call the keyPressEvent . At runtime the former gives "TypeError: Property 'keyPressEvent' of object myclass is not a function"

How can set pop-up menu position in QML

北城以北 提交于 2021-01-03 07:10:16
问题 I want to fix the position of pop-up menu in QML. When I click on a setting button,I want the pop-up menu will display at the fixed position. I did it by a day but can't. How can I do it in QML. Also, I want to change the size of menu item(width and Height). Hope your help! 回答1: That depends on QtQuick.Controls version. In 2.0 you can define size and position(and even more - you must do) import QtQuick 2.7 import QtQuick.Controls 2.0 //import QtQuick.Controls 1.4 import QtQuick.Window 2.0

How can set pop-up menu position in QML

岁酱吖の 提交于 2021-01-03 07:08:59
问题 I want to fix the position of pop-up menu in QML. When I click on a setting button,I want the pop-up menu will display at the fixed position. I did it by a day but can't. How can I do it in QML. Also, I want to change the size of menu item(width and Height). Hope your help! 回答1: That depends on QtQuick.Controls version. In 2.0 you can define size and position(and even more - you must do) import QtQuick 2.7 import QtQuick.Controls 2.0 //import QtQuick.Controls 1.4 import QtQuick.Window 2.0