qml

Easy way to configure QML combobox with 1-25

为君一笑 提交于 2019-12-13 03:45:35
问题 I have a need for a simple drop-down box containing the numbers 1 through 25 inclusive. If I set the model up as a simple 25 , I get the values 0 through 24 inclusive. I know I can have a more complicated list model but it seems rather silly to construct a massive array of values when they should be able to be calculated on the fly. From what I read, it should be a simple matter to create a delegate for setting the display values but, with the QML: ComboBox { width: 100 model: 25 delegate:

QSqlQueryModel reference error in roleName for ListView QML

萝らか妹 提交于 2019-12-13 03:45:33
问题 I want to get the model from my SQlite Database, when I set the query in the QSqlQueryModel I can get the number of rows, number of columns, etc. But the data inside each column I have a ReferenceError trying to get the name of the column The cpp code: //data base users QSqlQueryModel *sqlModel = new QSqlQueryModel(); sqlModel->setQuery("SELECT usuarios.nombre FROM usuarios"); sqlModel->setHeaderData(0,Qt::Horizontal, QObject::tr("nombre")); qDebug() << "ROL: " << sqlModel->roleNames();

QPushButton export to QML [duplicate]

Deadly 提交于 2019-12-13 03:10:11
问题 This question already has answers here : Qt5. Embed QWidget object in QML (6 answers) Closed 6 months ago . I am currenctly using Qt 5.7 and I have subclassed QPushButton with the basic idea of using Qt Style sheets on QML side. Here is header file: #ifndef LTPUSHBUTTON_H #define LTPUSHBUTTON_H #include <QWidget> #include <QPushButton> #include <QString> /** * @class Modified push button class */ class LtPushButton : public QPushButton { Q_OBJECT public: /** * @brief Constructor * @param

How to animate scroll in a QML ScrollView?

纵然是瞬间 提交于 2019-12-13 03:09:01
问题 How can I animate scrolling in a QML ScrollView? I've tried a Behavior on the contentItem.contentY , but that isn't working. 回答1: With Qt Quick Controls 1 You just have to animate the value changes on the property flickableItem.contentY . A quick example: Item { anchors.fill: parent ColumnLayout { anchors.fill: parent Button { id: btn onClicked: scroll.scrollTo(scroll.flickableItem.contentY + 100) } ScrollView { id: scroll function scrollTo(y) { scrollAnimation.to = y scrollAnimation.start()

How to scroll to certain row in QML TreeView

℡╲_俬逩灬. 提交于 2019-12-13 02:58:32
问题 In TreeView , selecting a row by clicking it. But I want to focus the row in TreeView by indicating the row QModelIndex and roleName . I found similar function in ListView : positionViewAtIndex(int index, PositionMode mode) How to do this in TreeView ? 回答1: Try to use hidden variable __listView. __listView.positionViewAtIndex(row, mode) 来源: https://stackoverflow.com/questions/46441998/how-to-scroll-to-certain-row-in-qml-treeview

Javascript/Node/Twilio - ReferenceError: require is not defined

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-13 02:56:15
问题 I have installed Node from: Node and run this in cmd: npm install twilio I then tried the example code provided by Twilio: var accountSid = 'MyAccountSidHere'; var authToken = "MyAccountAuthTokenHere"; var client = require('twilio')(accountSid, authToken); client.sms.messages.create({ body: "Jenny please?! I love you <3", to: "SomeNumber", from: "MyNumber" }, function(err, message) { process.stdout.write(message.sid); }); Saved this to MyFile.js file and double clicked it. I get the error

QML - what is the id and how does it work?

妖精的绣舞 提交于 2019-12-13 02:36:21
问题 Consider this project structure: MyComponent.qml: Item { id: innerId } Usage.qml: MyComponent { id: outerId } At first glance it seems like this creates a single object that has 2 different id's simultaneously. But that's impossible, if id is to be considered a property. To me it seems that an id is not so much a property of an object as it is a property of an object declaration . Is that true? It would explain how I can refer to the object as innerId in MyComponent.qml and as outerId in

loading data from database to expose in qml

北慕城南 提交于 2019-12-13 02:27:09
问题 I am new to QML, so please forgive my lack of knowledge. I am loading some data from my database - after clicking in a button - and I want to fill a ListView with it. This is my ListView: Rectangle { id:tblKules anchors.horizontalCenter: parent.horizontalCenter width: menuListaItem.width height:300 visible:false color: "#e5e6e8" ListView { id: listView anchors.fill: parent; anchors.margins: 5 model: mainController.listaDispositivos spacing: 1 delegate: Component { Rectangle { id:item width:

How can I listen to a C++ signal from QML?

爷,独闯天下 提交于 2019-12-13 00:54:23
问题 I have what I'm calling a C++ "service" who's interface I want to expose to QML. I'm trying to use QQmlContext's setContextProperty to link the object into the QML and connect to it from a QML Connections block. QML isn't complaining with a reference error as it did previously when I hadn't registered the service in the QML context: qrc:/main.qml:13: ReferenceError: service is not defined So, QML seems to find the service object now, however the QML slot javascript function is not getting

QML text rendering issue with custom OpenGL item active

梦想的初衷 提交于 2019-12-13 00:23:39
问题 I've been working with the QmlOgre Qt example to make it work with Qt5 final. The original example itself looks fine now and behaves as intended. My code is here: https://github.com/advancingu/QmlOgre However I found that there is an issue when a QML text item is modified either through changed signals emitted from C++ or from a simple timer in the sample QML scene. For example, I added a 10ms QML timer that simply increments a counter and assigns it to a text item. The corresponding code is