FAQ Database Discussion Community


What is the use of the ui.qml files in Qt5 (QML)?

qt,qml
As far as I can see the .qml files can be used to define the UI, which seems to override whatever is written in ui.qml file. So, what exactly is the use of the ui.qml file? I'm using Qt5 with Qt Creator....

Saving images read with glReadPixels where alpha value is not one

qt,opengl,qml,qtquick2
Please look at this image: On the left, there is an image saved using glReadPixels. On the right, the corresponding (correct) rendering: the colors are distorted where their alpha value is less than one. The surface is managed by QtQuick. With glGetInteger I found out there are 8 bits for...

how to assign a listmodel to a QML listview through the QQmlListProperty

c++,qt,listview,qml
if i have a class that contains a QList of listmodels (QList), how would i assign a model from that list to a listview in QML? class code: class TreeModel : public QAbstractItemModel { Q_OBJECT Q_PROPERTY(QQmlListProperty<ListModel> lists READ lists) public: enum AnimalRoles { TypeRole = Qt::UserRole + 1, }; explicit...

Can't emit signal in QML custom Item

qt,qml,signals-slots
I created my own Item with signal clicked, that contatins MouseArea. I want to emit signal clicked, when MouseArea is clicked. But nothing works. Here is my .qml code: import QtQuick 2.4 Item { id: baseButton property alias text: txt.text width: txt.width height: txt.height signal clicked onClicked : console.log("Clicked!") Text...

How to create delay function in QML?

javascript,qml,delay
I would like to create a delay function in javascript that takes a parameter of amount of time to delay, so that I could use it do introduce delay between execution of javascript lines in my QML application. The javascript lines I am talking about would trigger animation of some...

QML: Using a Canvas in a RadioButtonStyle

qt,qml,qt-quick
Using a Canvas inside a RadioButtonStyle doesn't seem to work. Consider this simple example: // MyRadioButton.qml import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Controls.Styles 1.3 RadioButton { id: base implicitHeight: 24 style: RadioButtonStyle { spacing: 4 indicator: Canvas { id: circle anchors { left: parent.left verticalCenter: parent.verticalCenter } height: 16...

How to get system, user info with pure qml linux

linux,qt,qml,kde,plasmoid
I am preparing pure qml plasmoid for my new panel appereance in KDE Plasma 4 and I have to use at most Qt 4.7 library and Qt.Quick 1.1 for that. Is it possible to pick up current user's fullname? Is there any plasma API related to that like PlasmaCore or...

Partial update repeater QML

qt,qml,qtquick2
I'm facing a little issue with QML/C++ project. I'm using a repeater to draw points inside a Rectangle and those points come from a model. Here is my code : main.qml Rectangle { id: rect height:500 width:500 Repeater { id: pointsRepeater model: qListPoints Point { } } } qListPoints come...

Share array or list between C++ and QML via property

c++,list,properties,qml
There's a list of unsigned ints in C++ class. The list can be modified inside the class in some way. There's a QML object that has to use this list. How should I declare the list to make the object able to use the values from the list and after...

Fill QML ListModel from nested models

qt,qml,qtquick2
I have the following C++ model structure: Manager // QAbstractListModel ↪ Slot // QAbstractListModel ↪ Processor // QAbstractListModel ↪ name // Q_PROPERTY I pass only the Manager reference to QML on instantiation. I need to fill the ComboBox with Processor names but I don't know how to fill up with...

Is there any QML window UI fully constructed signal?

qt,qml,qtquick2
I've found this, but it is only about QWidget based project. What about ApplicationWindow components in QML?

QML ScrollView with ColumnLayout

c++,layout,qml,qt5
I am trying to create a scroll view around a ColumnLayout, unfortunately my current code doesn't work. I know about ListView, but in my case I need to create scrollable Layout, because it will contain heterogeneous elements. ApplicationWindow { id: mainwindow title: qsTr("Hello World") width: 300 height: 300 visible: true...

DPI-independent constant size in QML

qt,qml,qt5,qtquick2,qt-quick
I have a visual component in my app written in QML, Qt5. I want it to always have the width of 5 cm on the screen, no matter what device is used. If I set width: somevalue, then the DPI might differ among the devices which will result in different...

How to import the QML-Book examples into QT Creator 3.4.0?

qt,qml,qt-creator
How can I import these code examples into QT Creator 3.4.0 ? I tried the available import options but they don't work. I tried to create an empty QML project and add the rectangle.qml file to it. When I tried to run it, nothing showed up. The book examples contain...

Using a C++ class variable in QML file

c++,qml
How can I use a C++ class variable in QML file in Qt. I want to set a variable based on Q_OS_Android in c++ file and evaluate a condition in QML file. How will this be possible?

Сreate a copy of a rectangle in QML

qt,qml,qtquick2,qt-quick
I want to make an area, where a small rectangles appear in the places it where clicked. Later on I would try to add an ability to move those rectangles by dragging. After studying Help, I tried to accomplish this with a MouseArea and a Component containing a Rectangle. Then,...

How to set the default button of a MessageDialog in QML?

button,qml,messagedialog
The default button is "Yes", but I want to set the button "No" as the default button. How to do it?...

Align horizontalcenter in Column

qt,qml,qtquick2,qt-quick
Column documentation explains how to achieve this: However, I would like to achieve this: That is, all items inside the Column should be horizontally aligned to the center. anchors.horizontalCenter: parent.Center does not work. How can I obtain the desired result?...

Set rotation point of Rectangle

qt,rotation,qml,qtquick2,qt-quick
Is there a way to set rotation point in Rectangle and simply use rotation property without any other additional component? I want to rotate a Rectangle with binding property of rotation: value * 180 like this Rectangle{ id: body rotation: value anchors.centerIn: parent.Center antialiasing: true } onValueChanged: body.rotation = value...

Statically link Qt application with QML

c++,qt,qml
I am trying to statically link a Qt application which uses the QML module. Previously when it did not include QML I was able to build and link it statially. In the compile output I get the following message: 'C:\Qt\5.4\qtbase\bin\qmlimportscanner.exe' is not recognized as an internal or external command, operable...

Passing 2-dimensional QVariantList from C++ to QML

c++,qt,qml
I am really confused on how to pass a 2-dimensional QVariantList from C++ to QML, I basically want to pass a value from C++ which will do the same as assigning it in QML like this: property var twoDim: [["1-1", "1-2"],["2-1", "2-2"]] So that I can use the array as...

Undefined element when tab is not active

qt,qml,qtquick2
When I try to access a son of a Tab element, if it is not active QML throws an error saying is undefined. main.qml import QtQuick 2.4 import QtQuick.Controls 1.3 import QtQuick.Window 2.0 ApplicationWindow { TabView { Tab { id: mytab1 } Tab { id: myTab2 Rectangle { //(...) }...

catch mouseMoveEvent on Qt5's QQuickItem

c++,qt,qml,qt5
I'm following the reply of my previous question. But I got stuck U_U. I'm developing a Qt5 application where I want to catch mouseMoveEvent event when the mouse hovers a QQuickItem item. But I don't know how to make it work. I have isolated the problematic code (using this code):...

QML XmlListModel messes sorting when delegated

qt,canvas,qml,qtquick2
I'm trying to get a Canvas to draw lines in the same order as presented in this xml-file: <root> <doc><nopeus>80.0</nopeus><aika>40.0</aika></doc> <doc><nopeus>110.0</nopeus><aika>80.0</aika></doc> <doc><nopeus>120.0</nopeus><aika>120.0</aika></doc>...

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

c++,qt,qml,qt-creator
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...

Maximize Rectangle to fit application window QML

qt,qml
I need to make one Rectangle in QML maximize when user make double click on it. To do that, I define a Rectangle that contains MouseArea with onDoubleClicked handle. My question is: What I need to put in this handle to make Rectangle fit with app window maximized (not fullscreen,...

Qt application trying to load platform plugin “xcb” instead of “eglfs”

arm,qml,qtwebkit,yocto,qt5.4
Built Raspberry Pi 2 linux distro including Qt5.4 + QtWebKit + QML plugin using Yocto on fido branch See tutorial Testing with the following QML script [email protected]:~# more webkit3.qml import QtQuick 2.0 import QtQuick.Controls 1.0 import QtWebKit 3.0 ScrollView { width: 640 height: 480 WebView { id: webview url: "http://qt-project.org"...

Difference between child object and object as property?

qt,qml
I'm wondering what's the difference between a child object or an object as a property: Rectangle { Button { id: myButton } } and Rectangle{ property Button myButton: Button { } } I know that you can access the button in the first example (via id) from more places in...

Undefined reference to QDeclarativePropertyMap in qt

c++,qt,qml
I am new to Qt. Qml is facing issue while passing QDeclarativePropertyMap from c++ to Qml. Here is my code: main.cpp #include <QApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include <QtDeclarative/qdeclarativepropertymap.h> #include <QVariant> int main(int argc, char *argv[]) { QApplication app(argc, argv); QQmlApplicationEngine engine; ///giving error in below line QDeclarativePropertyMap *m_propertymap =...

How to add items dynamically to VisualItemModel in QML?

javascript,qt,listview,qml
I have a custom qml element based on a textbox. I want that whenever the user presses on the last textbox in the VisualItemModel, a new textbox is added automatically. There is a way to do this with ListModel (using append()), but nothing with VisualItemModel. How to do this? Even...

QTimer::singleShot equivalent for QML

qt,qml
Consider this C++ statement (example from docs): QTimer::singleShot(600000, &app, SLOT(quit())); How to do the same in .qml JavaScript, something like this QML: Rectangle { property int counter: 0 onCounterChanged: { if (counter > 42) { // do equivalent of above C++ statement here } } // more code, which actually...

How to avoid repetitive code in QML?

qt,qml,generalization
I'm using Qt 5.4.1. I'm currently setting up some buttons in QML. I want similar state behaviours for some of the buttons - how to do I avoid having large chunks of very similar code repeated through the QML? Rectangle { id: songFilterButton x: 0; width: 80 y: 0; height:...

Embed child in child of a custom type

qt,qml
I'm creating a custom type in QML that has a Column inside a GroupBox. When users of the type add components to CustomType, they should be inside the Column, not GroupBox. How can this be achieved without making extra wrapper files? //CustomType.qml GroupBox { Column { } } //main.qml CustomType...

Deploying to Android results in file not found after adding QtQuick Controls

android,qt,deployment,qml,qt5.4
After importing QtQuick.Controls 1.2 and using StackedWidget component, I now get an error when deploying to Android as seen below. The missing file AnimationDrawable.qml is not missing from the Android build directory so I do not understand why it is not packaged with the APK. It deploys fine when I...

QtQuick2 - QML reusable item focus changes when selecting/clicking outside/inside of root item

javascript,qt,focus,qml,qtquick2
How can I implement focus changing state into reusable QML component when I clicked or selected another item outside component body to call any event (highlight text, show/hide rectangle and etc). There is code I trying to implement highlight line under CheckBox text when item have focus, and hide that...

QML: is it possible to change the long duration of a mouse Area

qt,qml
QML provides in its MouseArea component a PressAndHold signal, when a mouse area is pressed for a "long duration" http://doc.qt.io/qt-5/qml-qtquick-mousearea.html#pressAndHold-signal this duration is set to 800ms, and I find nowhere a way to modify this duration. Can it be done and if so, how can I do that? Thanks!...

QML: Make property readonly in derived class

qt,qml
I'm pretty sure the answer is no, but I thought I should ask anyway. Can an inherited property be made readonly/constant in a pure QML derived class? // Base.qml Item { property int foo: 42 } // Derived.qml Base { foo: 99 // Make constant somehow! } I'm currently tackling...

Diiference between setContextProperty and setProperty of object

c++,qt,qml,qtquick2,qt-quick
I really confuse right now What's is the difference between QQmlApplicationEngine engine; engine.rootContext().setContextProperty("myObject",&userData); and object->setProperty("myObject", myObject) Here is the QML file ApplicationWindow { id: applicationWindow1 Item { id: propertyHolder property MyObject myObject } I had read how to use QML binding but still hasn't figure it out. Please help Thanks...

Auto-Fit Canvas element

qt,canvas,html5-canvas,qml
I'm working with Qt 5.4. I have a Qt Quick Project and I'm using QML. For some reasons I have to use the Canvas element to draw a tree. In some cases, my tree is larger than my Canvas element (400x800). So, my question is: how can I auto-fit my...

What is the right way to use QQuickImageProvider?

c++,image,qt,qml
I need to select dynamically qpixmaps to display inside QML Image items. That qpixmaps should be cropped from the source qpixmap, which I'm going to set from the QML file. I'd like them to be cropped by C++ code on the first demand from QML and to be cached for...

Invert ListView without filling the ListView from the bottom

listview,qml,qt-quick
I want a ListView to invert the order of its items, so that the most recent item is at the top. I tried to achieve this using verticalLayoutDirection: ListView.BottomToTop, but it makes the ListView fill up from the bottom (as to be expected, I guess). I marked the actual bounds...

Multiple “when”-conditions for a State

qml,state,qt-quick
Say I have following states: State { name: "red_state" when: color === "red" }, State { name: "blue_state" when: color === "blue" }, State { name: "square_state" when: shape === "square" }, State { name: "circle_state" when: shape === "circle" }, State { name: "blue_circle_state" when: color === "blue" &&...

qt 5.4 qtwebview: failing to load local HTML from qrc on android

android,qt,webview,qml,qwebview
I'm trying to load a local HTML file into a Qt 5.4.1 QtWebView: import QtQuick 2.2 import QtQuick.Controls 1.1 import QtWebView 1.0 ApplicationWindow { visible: true title: webView.title WebView { id: webView anchors.fill: parent url: "qrc:/index.html" } } The HTML file is referenced in the qrc, and everything works as...

Can't close the window with button: QML

qt,qml
I've created an item, that contains a button. I'm trying to close parent window of item with this button, but I'm getting this message, when click the item: TypeError: Property 'close' of object QQuickRootItem(0x1d8efed8) is not a function Can you help me with this? Code of item: import QtQuick 2.4...

How to display TextField at the bottom of the screen

qml,textfield,qtquick2,sailfish-os
I want to display a TextField at the bottom of the screen in QML for SailfishOS. I attempted multiple tries but the TextField is always at the top of the screen. import QtQuick 2.0 import Sailfish.Silica 1.0 ApplicationWindow { id: screen anchors.fill: parent Item { width: parent.width; anchors.bottom: screen.bottom TextField...

detect when mouse cursor is over an irregular shape picture in Qt5 and QML

qt,qml,qt5
I'm developing a little application with Qt5 and QML (QtCreator and C++). I would like to display a map with countries and when user passes the mouse over a country I would like to change the color of the country, thought it would be easy, and it is if all...

QML: Lambda function works unexpectedly

javascript,qt,lambda,qml
I thought QML supported lambda functions because of JavaScript's support of anonymous functions and the fact that functions are first class objects, but they don't work how I expected. Take this code: Item { property var items: [] function handler( item ) { console.log( item ); } Component.onCompleted: { for...

Animating the color of QML rectangles after a button is clicked

c++,qt,qml
I am trying to get my board to flash green when a button is clicked. I have added the following color animation code to help create the flashing effect, so that the board can go from its original colors, to green, and back to it's original colors. I have seen...

How do I create a Qml component from C++?

c++,qt,qml
I tried to use QQmlComponent component(view.engine(), QUrl::fromLocalFile("MyItem.qml")); and then QOObject *object = component.create(); but it gives me Qml Component not ready. Further tried to connect the statusChanged signal to a slot function, but it doesnt seem to load the new qml components. QQuickView view; view.setSource(QUrl(QStringLiteral("qrc:/main.qml"))); QQmlComponent component(view.engine(), QUrl::fromLocalFile("MyItem.qml")); QObject *object...

Editing a TextInput in a ScrollView

qt,scrollview,qml,qtquick2,qtquickcontrols
I have an issue with my QML. I'd like to edit a TextInput based on an action, setting the focus attribute to true. It works when the TextInput is located in a Rectangle, but not in a ScrollView. Here is an example: Item { id: main width: 640 height: 480...

Animating using NumberAnimation and Behavior

qml
I'm trying to understand the functionality of Behavior by animating a small Rectangle when it's property changes. Consider the following example: import QtQuick 2.4 import QtQuick.Controls 1.2 Item { width: 600 height: 80 Rectangle { id: rect color: "red" width: 20 height: 20 property int xval: 0 Behavior on xval...

How to close Pyqt5 program from QML?

qt,python-3.x,qml,signals-slots,pyqt5
I started a project in Qt Creator initially with a C++ backend, but then switched it to use PyQt5. I have a main.qml, where when I press a button called Exit, I call Qt.quit(). However, I get a General Message stating: Signal QQmlEngine::quit() emitted, but no receivers connected to handle...

How can I dynamically change a Flickable's contentHeight?

javascript,qt,qml
I have a simple Flickable with a Grid in it. Using the scroll wheel, I append objects to the grid. What I'm trying to do is alter the Flickable's contentHeight once the Grid elements exceed the default contentHeight. Here is my code: Flickable { property real flickHeight: Screen.height * 2...

Qt: Compiler is out of heap space

c++,qt,qml
I received this error when I added more music my resources.qrc. The mp3 files are not even that big, you have got to kidding me that this is all the MSVC compiler can handle. Is there anyway around this? Is it impossible to increase the heap space for a compiler?...

QtQuick: QQmlApplicationEngine failed to load component qrc:/main.qml:23 Invalid attached object assignment

c++,qt,qml,qt-quick,qt5.4
Given my thoughts below am I barking up the wrong tree? Or provided the information below am I misusing Qt API to get the error in the title? I am trying to modify the sample at http://doc.qt.io/qt-5/qtquick-scenegraph-openglunderqml-example.html to work with the default QtQuick project generated with Qt Creator 3.3.0 (opensource)...

Using Sqlite in Qt (Qml File)

qt,sqlite,qml
I have the weirdest error ever using sqlite, I'm trying to connect to a database, create a table, insert some values & reading them later on, Simple enough isn't it, but the weird thing is that i'm getting an error in one part of my application unlike the other part...

How to add items to a QML Grid after creation?

javascript,qt,qml
I've done a bit of searching but I've failed to find an answer which must be so simple it hasn't warranted a question thus far. Anyway I'm new to QML and struggling to find a way to add items to a Grid dynamically post-creation. Basically I have a Flickable with...

Why Qt QML doesn't properly bind properties?

c++,qt,qml,qt5,qtquick2
It's very weird because I use almost the same pattern in another QML file and it works correctly! I'm sure I'm not reassigning value anywhere (the only thing I know that can make property static)! I have something like this (it's a simplified example and probably works as expected): Item...

Qt5: function.toString() not working

javascript,qt,qml,qt5
I use Javascript in my QML application and want to insert the code of a function as string: function test(parameter) { console.log("Something to do!"); } ... function otherFunction(otherParam) { console.log("Output: "+test.toString()); } All this does is to print the following: "Output: function() { [code] }" instead of the desired string:...

Exposing an enum in a QML signal

c++,qt,enums,qml
I have problems receiving the signal mySignal with the correct enum type in qml. I think I have done everything right: The enum is in a separate class, derived from QObject The enum is registered with Q_ENUMS The class containing enum is registered with qmlRegisterUncreatableType The class the signal is...

Qt Creator doesn't display QML folder

qt,qml,qt-creator,qtquick2,qt-quick
I have a Qt project in Qt Creator. I have a qrc file with the QMLs registered and everything works. However for some reason the "projects" view of Qt Creator doesn't show the QML folder (screenshot attached) like it does for any example project. I'm just curious. Why does QML...

Context2D.putImageData doesn't work

canvas,qml
I am trying to push pixels on a QtQuick Canvas import QtQuick 2.4 import QtQuick.Window 2.1 import QtQuick.Controls 1.2 ApplicationWindow { Canvas { id: canvas width: 500 height: 500 Component.onCompleted:loadImage('kde.png'); onImageLoaded:requestPaint(); onPaint:{ var ctx = getContext("2d"); if (canvas.isImageLoaded('kde.png')) { var im = ctx.createImageData('kde.png'); im.data[3] = 128; ctx.putImageData(im, 0, 0); }...

QML: Can I draw a rectangle from its center, not from its corner?

qml
If I want to visualize a point in qml i could do something like this: import QtQuick 2.4 import QtQuick.Window 2.2 import QtQuick.Controls 1.2 import QtQuick.Layouts 1.0 ApplicationWindow{ width: 1024 height: 256 visible: true ColumnLayout { anchors.fill: parent Rectangle { x: 10 y: 10 width: 5 height: 5 color: "white"...

Qt: symbol(s) for not found for architecture x86_64

c++,qt,class,qml
I'm new to Qt and just to programming in general, and I'm having some issues adding a score to a game I'm making. I have a score class, obstacle class, and a game class, among others, and I'm trying to connect the QTimer currently used to spawn obstacles to update...

setting wrapMode property of Text in ScrollView

qt,qml,qt5,qtquick2
I wrote QML like this: import QtQuick 2.2 import QtQuick.Controls 1.1 import QtQuick.Layouts 1.1 import App 0.1 ApplicationWindow { id: appWindow visible: true width: 300 height: 500 ColumnLayout { ScrollView { ColumnLayout { Text { width: 250 text: "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor...

Insert QML code in Jade

javascript,node.js,express,qml,jade
I'm writting a simple video streaming app with Node.js and I'm using the WebChimera plugin. With chimera, the player config is written in QML and I must include it in my .jade page and of course, there's many errors when jade compiles. Is there a way to include QML in...

Can't use DropShadow in Column?

qt,qml,qtquick2
I was developing a small application using QML, and i need a small drop shadow on the text component, to make it more readable, but when I add the DropShadow to the Label in the Column, it throws an error: "QML Column: Cannot specify top, bottom, verticalCenter, fill or centerIn...

QML/Qt4 for desktop: any demos? [closed]

qt,qml,qt-quick
I want to build a simple desktop application using QML (need nice transition animations), but i can't find any demos. The demos on qt docs website are using some shared files i can't find (and anyway they have both pro and QML pro while my application has only one view,...

QML: animation only when mouse enters image

qt,qml
I would like to make an animation when mouse comes over the image, but NOT when mouse leaves the image. Item{ width: 800 height:800 Rectangle{ id: blueRec width: 100; height: 100; color: "blue" MouseArea{ anchors.fill: parent onClicked: { im1.visible = true im1.source = "1.png" } } } Image { id:...

how to load a new screen in QML showing a new list based on previous user click input?

qt,listview,qml
In my application i show a nested list, that shows groups and folders as its children. I have built the functions necesary to generate a new list in the backend in c++ based on which item is clicked by the user. I allready have the necesary functionality to pass the...

QML MouseArea Overlap other widget

qt,qml,qtquick2,qtquickcontrols
Here is some simple QML code which contains a Button and a MouseArea. I want the Button to detect both left and right mouse clicks. Rectangle { anchors.fill:parent; width: 1302 height: 638 Button { id: button1 x: 378 y: 332 width: 194 height: 66 text: qsTr("Button") } MouseArea { id:...

QML ReferenceError: is not defined from Js function called from a qml file

javascript,qml,loader,stackview
Ok definitely not know what to do so I ask for help, I've looked everywhere and can not find solution. This is a long question involved the following files: sizeCalc.js, main.qml, MainForm.ui.qml, VentPrinc.qml and menuPrincElement.qml, the problem is this. Inside the file MainForm.ui.qml have the structure of the main window...

QML is not recognising C++ functions

c++,qml,integration
I am trying to implement my c++ class into QML, the class is recognised by setting the context property and I can successfully call the class and see all the functions but on runtime they are not recognised and returns the error: TypeError: Property 'getSrcImage' of object Wrapper(0x7b211cbf10) is not...

deploying c++/qml application - packing qml files into bin

c++,qt,qml
I have a c++/qml applicaiton. My/custom qml files are packed in a resource file and loading well. My problem is that when I deploy my application I need to have in bin directory also all the QtQuick/QtQuick2 directories with all their content. Is there a way to have them packed/included...

Why does adding a MouseArea with anchors.fill: parent cause the rows to stack up on one another?

qml
Given that this ListView works fine: ListView { id: myListView model: myListModel anchors.fill: parent delegate: Row { id: row spacing: 5 Text { text: id width: 25 horizontalAlignment: Text.AlignHCenter } Text { text: description } } } Why does adding a MouseArea with anchors.fill: parent cause the rows to stack...

How to connect a destroyed signal of C++ object from QML?

javascript,qt,qml,qtquick2
I want to connect a destroyed signal of C++ QObject from QML so I did this: Rectangle { id: root width: 128 height: 128 Button { anchors.centerIn: parent text: "Click me" onClicked: { qobj.Component.onDestruction.connect(function(){console.log("It destroy")}) // qobj is set from c++ qobj.destroy() // should output "It destroy" } } But...

where and what to learn to use Qt5? [closed]

c++,qt,qml
I tried to use Qt5 but I find it very confusing. I have good knowledge of c++(I would say between intermediate-expert level) but no knowledge of javascript or QML(only basic HTML) When I go through the examples and tutorials provided with Qt, I find then more to be reference material...

What does QByteArray get converted to in QML?

javascript,qt,qml,qbytearray
If I have a signal: void foo(QByteArray data); And in QML I handle it: onFoo: { console.log(data.toString()); } What is the type of data in QML? What methods does it have? It doesn't seem to be a javascript string - it doesn't even have a .length, and no .charCodeAt(). But...

Refresh QML Listview from Slot

c++,qt,listview,qml,slot
I have problem with the refreshing Listview in QML I looked through many solutions but there is nothing concrete i want from event "onClicked" refresh all listview but how to do this? sourcecode: http://s000.tinyupload.com/?file_id=86538244635919176055 main.cpp #include <QApplication> #include <QQmlApplicationEngine> #include <QQmlContext> #include <QDebug> #include "message.h" #include "dataobject.h" int main(int argc,...

How to make QtQuick transparent Toolbar

qml,toolbar,qt-quick,qtquick2
How to make the built-in Quick ToolBar transparent so that only buttons are visible?

Dynamically creating elements with text from a global property in QML

qml
I am creating some Rectangles dynamically with a Text element inside like so: Rectangle { id: root width: 640; height: 480 property var items: [] property int count function push() { var temp = Qt.createQmlObject("import QtQuick 2.3; Rectangle {width: 100; height: 30;color: 'yellow'; Text {text: count; anchors.centerIn: parent}}", root, "")...

QML visible property in Grid delete Item

qt,qt4,qml
I'm trying to create a QML keyboard with the following code on Qt4.8. Item { id: keyboard property string keys: "azertyuiopqsdfghjklmwxcvbn****^<" Rectangle { height: parent.height width: parent.width Grid { id: keyboardGrid rows: 4 columns: 10 spacing: 1 Repeater { model: keys.length KeyboardButton { visible: { (keys.charAt(index) == "*") ? false...

QML + .qrc: Keeping images under another prefix

qt,qml
My problem has been similar to that discussed in another stackoverflow discussion and I could get my code working that way. However, I'm not completely satisfied with that solution. Initially, I had my .qml-file under one prefix ("/") and my images under another ("/images"). Without abandoning this separation, I don't...

Access Flickable from parent element

qml,qtquick2,flickable
I'm trying to call a function which is defined inside a Flickable element, but it seems impossible to access it by id. The following code produces ReferenceError: flickable is not defined when tab.getValues() is called: import QtQuick 2.4 Tab { id: tab function getValues() { flickable.getValues() } Flickable { id:...

How to rotate an element on both axes with different angle values

qt,qml
If you need to rotate an element in QML in order to achieve a sort of 3d flip effect then you can do transform: Rotation { origin.x: 30; origin.y: 30; axis { x: 0; y: 1; z: 0 } angle: 24 } How can I achieve the same thing but...

How to set User Agent in QtWebEngine QML application

qt,qml,qt5,user-agent,qtwebengine
NOTE: I was able to do that on QtWebKit QML using the QtWebView extension. Here I am interested in using QtWebEngine. My simple test application import QtQuick 2.1 import QtQuick.Controls 1.1 import QtWebEngine 1.0 ApplicationWindow { width: 800 height: 600 color: "lightgray" visible: true WebEngineView { id: webview url:...

Qt.inputMethod.show () doesn't show any keyboard

qt,qml,qt5,qtquick2
Considering "Property and Method Changes" from here: TextInput and TextEdit's openSoftwareInputPanel() and closeSoftwareInputPanel() methods have been removed. Use the new Qt.inputMethod property and call Qt.inputMethod.show() Qt.inputMethod.hide() to show and hide the virtual keyboard. I've written the simple example below. import QtQuick 2.3 import QtQuick.Window 2.2 Window { id: root visible:...

How to set the drag area in qml windowless application

c++,qt,qml
my question is how can i set to drag the app without window-decorations i have seen so many apps which are drag-able through desktop with mouse. my app uses Qml so any possible way do get this work thanks .

Even width of Text and Textfield

qt,qml,qt5,qtquick2
I have a simple login form written in QML with a custom component, MediumText, and two TextFields. Unfortunately, I'm not able to properly align the elements, as shown by the following picture: I want the labels to the left (MediumText type), as well as the TextField instances on the right,...

Pass custom C++ object to Qml error (no properties)

c++,qt,qml
I am trying to write code that will pass some data from C++ engine to the Qml scripts via signal, but it looks like that I doing some thing wrong, because when I receive signal in Qml my object don't any method or properties! Look at that code: Signaller -...

Repeat state on mouse click QML

qt,qml,qtquick2
Within the code I have a State, a Transition and a RotationAnimation defined. After the property change takes place, i.e. after the rotation is set to 360, the onClicked handler is rendered mute and the animation will never be played again after subsequent MouseArea clicks. Here is my current code:...

Drag after long press

qt,qml,drag,qtquick2
I want to drag my custom buttons QML after a long press over them. I've implemented that behaviour, however the problem is that after enabling drag, I need to press button once again to actually start dragging. How should I implement this mechanism if I want to move buttons without...

Properly reloading a QQmlApplicationEngine

qt,qml,qqmlapplicationengine
I have a QML-based app that loads a main.qml file from the file system like this: myEngine->load("main.qml"); This works fine, but I'd like to "reload" the engine in case the main.qml was replaced with a newer version. What I tried so far was calling load() again, assuming that the engine...

QtQuick2 - QML - create infinite moving line animation

javascript,animation,qml,infinite-scroll,qtquick2
Does anyone know how to implement linear animation, for example like in progress bars, where few of lines moving infinite in the bar from left to right or any other way? I'm going to use only QtQuick2 primitives and without any additional C++ components, glad to see any answers that...

MouseArea event is propagated to its parent sibling. Why?

qt,qml,qt-quick,qtquick2
Here's a code snippet with current form of the code Rectangle { id: menu GridLayout { id: layout columns: 4 rows: 3 Repeater { model: ListModel {} ToolButton {} } Rectangle { x: -3 y: -33 width: menu.width - 2 height: menu.height + 33 border.color: "red" border.width: 3 color: "blue"...

Update bindings to var properties in QML

qt,qml
If you take a look at this page it notes that bindings to var properties are not automatically updated when the object changes: Item { property var car: new Object({wheels: 4}) Text { text: "The car has " + car.wheels + " wheels"; } Component.onCompleted: { car.wheels = 6; }...

QT5 qml receive c++ object in slot

qt,qml,qt5,qtquick2
i want to send a c++ object to QML via signal-slot. class TaskInfo : public QObject { Q_OBJECT Q_PROPERTY(QString name READ taskName) ... // constructors public: TaskInfo(); TaskInfo(QIODevice *in); TaskInfo(TaskInfo &&taskInfo); TaskInfo(const TaskInfo &taskInfo); // it's just copy all variable ... } and i have a class to send TaskInfo...

QML. How to stretch Grid for all parent space

qt,qml,qtquick2
I have a custom button: import QtQuick 2.0 Rectangle { id: xobutton width: 100 height: 100 property string label: "?" border.width: 2 Text { id: xobuttonLabel text: label font.pointSize: 75 anchors.centerIn: parent } } It has a parent Rectangle: Rectangle { width: 500 height: 500 Grid { anchors.centerIn: parent rows:...

qt: invalid property name 'x' (M16) for button

qt,qml
I'm using Qt 5.4.1 in QtCreator 3.3.1 I've imported QtQuick.Controls 1.2 into my QML and added a series of buttons: Rectangle { id: buttonBar x: 480 y: 0 width: 320 height: 80 Button { x: 0 y: 0 width: 80 height: 60 text: "Songs" } Button { x: 80 y:...

is it possible to show only certain indexes of QML listview?

qt,listview,qml
Is it possible to show only certain indexes or a range of indexes in QML listviews? i have a listmodel that has a bunch of info that i am reusing. Would it be possible to have a list show for example only index 5 to 8?...