Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.0k Topics 77.4k Posts
  • Alternatives to Component inside a Component

    4
    0 Votes
    4 Posts
    1k Views
    shavS
    Hm.... I'm using Window component to create dialogs. So, when I need to create custom dialog I use something like this: @ import QtQuick 2.2 import QtQuick.Controls 1.2 import QtQuick.Window 2.0 Window { id: controllerWindow width: 600 height: 300 minimumWidth: 600 maximumWidth: 600 minimumHeight: 300 maximumHeight: 300 modality: Qt.WindowModal title: qsTr("Window title") color: "#e8e8e8" //Any properties, functions etc. Rectangle { id: generalTabContent anchors {fill: parent; margins:10} color: "transparent" Rectangle { id: generalContentView width: parent.width height: parent.height - 10 - buttonsRow.height color: "red" } Row { id: buttonsRow anchors {top: generalContentView.bottom; right: parent.right; topMargin: 10} width: btnClose.width + btnSave.width height: btnClose.height Button { id: btnClose text: qsTr("Close") onClicked: { controllerWindow.close(); } } Button { id: btnSave text: qsTr("Save") onClicked: { //Some code here controllerWindow.close(); } } } } } @ Certainly, you can create qml file with code upper and implement all logic in this qml file. If you need to return some datas in this case you can use "signal/slot.":http://qt-project.org/doc/qt-5/qtqml-syntax-signals.html Also you can set any properties (custom properties you must implement in you Window qml file) in opitions variable. If you have any question let me know and I'll try to help you.
  • How can I save a ListModel in Qt Quick ?

    2
    0 Votes
    2 Posts
    2k Views
    dheerendraD
    Welcome to forum. You need to extend QAbstractitemModel in C++ and expose it QML. Extended class need to have save method to save contents to file or any local storage. When you are start QML app, read from the data from storage and build your model and expose it. Look at examples given in your installation under examples directory (\examples\quick\models)
  • Changing the content of qmldir at runtime

    5
    0 Votes
    5 Posts
    1k Views
    T
    Hello, If I don't add qmldir into qrc; the relative path is ok. For ex: ../Plugin. But if I add qmlfir into qrc, QmlEngine can't understand the current path to specify the location of Plugin, so I need to use the absolute path: /home/myname/plugin . Do you have other solution ? Thanks
  • [SOLVED] TableView remove all selected items

    5
    0 Votes
    5 Posts
    2k Views
    L
    I have found a solution. You have to use the private __ranges array of the selection object. Here is my solution: @ function removeSelectedRows() { for (var i = selection.__ranges.length - 1 ; i >= 0 ; -- i) { var index = selection.__ranges[i][0]; var count = 1 + selection.__ranges[i][1] - selection.__ranges[i][0]; model.remove(index, count) } selection.clear() } @
  • Will QQuickWidget be supported on Android/iOS in the future?

    3
    0 Votes
    3 Posts
    1k Views
    C
    Ok - thanks.
  • 0 Votes
    3 Posts
    666 Views
    D
    Yap, that is something I was thinking about, but there is no onRemove for Component or Item (The types my delegate for the list consists of and where the reference to the timer is held). Where can I catch onRemove? edit: Ok, figured it out. Had to use @ ListView.onRemove: { console.log("Remove") }@ On the first Item in the delegate (not one of the children) and it worked. Still strange that the QtCreator code completion doesnt "know" about the onRemove signal from ListView.
  • About QquickWidget has a black background

    1
    0 Votes
    1 Posts
    879 Views
    No one has replied
  • Multi Screen QML App

    2
    0 Votes
    2 Posts
    2k Views
    p3c0P
    Hi, How about using a "StackView":http://qt-project.org/doc/qt-5/qml-qtquick-controls-stackview.html ? You can load your Screens1 ... n whenever required. Here's a working "example":https://qt-project.org/doc/qt-5/qtquickcontrols-touch-example.html.
  • Extending QML - Styling design principles?

    7
    0 Votes
    7 Posts
    2k Views
    T
    Aren't you just supposed to set the public properties which determine the visuals of the calendar? The event handlers are there for the Calendar to "work", but we as users should only worry about the visuals.
  • Font hinting from QML

    1
    0 Votes
    1 Posts
    782 Views
    No one has replied
  • Use QAction (c++) in QML Menu

    3
    0 Votes
    3 Posts
    1k Views
    L
    Thanks for the answer, I wanted to be sure that there is no other way :)
  • Set icon to qtquick application in OS X

    2
    0 Votes
    2 Posts
    938 Views
    shavS
    Hi, Did you try to move you icon file to folder where you .pro file is saved? Also you must check the plist file. If you want to use custom plist file you must add this line to you pro file: @ QMAKE_INFO_PLIST = Info.plist @ In plist file must have this lines: @ <?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> <plist version="1.0"> <dict> <key>NSPrincipalClass</key> <string>NSApplication</string> <key>CFBundleIconFile</key> <string>icon.icns</string> <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleGetInfoString</key> <string>Created by ...</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleExecutable</key> <string>app_execute_file_name</string> <key>CFBundleIdentifier</key> <string>com.company.appname</string> </dict> </plist> @
  • QML Connecting two or more QML files

    3
    0 Votes
    3 Posts
    878 Views
    T
    If I were you, I would have a look to "ListView" to easily have a swipe (see orientation to have a vertical view). Set the property model to 7. Now, use Loader to choose the correct Qml component according to the index. It should be something like this : @ListView { Component { id: dayLoader; Loader { source: { if(index==0) return "MondayView.qml"; if(index==1) return "TuesdayView.qml"; ... } } model : 7; delegate : dayLoader; }@ I hope it helps...
  • Rotating an image is clockwise or anticlockwise

    2
    0 Votes
    2 Posts
    880 Views
    dheerendraD
    You need to get the x and y of mouseevent and do mathematical calculation. I'm sure there will some ready algorithm available in the net. Any reason you don't want to use roation changing property ?
  • [SOLVED] StackView: check what the currentItem is?

    3
    0 Votes
    3 Posts
    6k Views
    E
    Thank you, that works. I also learned that objectName must be a property already declared in the qml file of the page I want to push, it won't be attached at runtime by the push function. Not a problem, since declaring, in each page, a string property with the page name makes perfect sense.
  • [Solved] Iterate through children of a QML Item ?

    5
    0 Votes
    5 Posts
    27k Views
    S
    Thanks for explaining, now I also understand why, what a luxury !! :-)
  • Use Style for QtQuick.Controls from Resources file

    10
    0 Votes
    10 Posts
    3k Views
    p3c0P
    That is what i explained in the 2 & 3 post :) I'll try to explain again. Consider MyButtonStyle.qml and main.qml are QML file's which are present in your Resources file. MyButtonStyle.qml contains your style Component, it's contents are: MyButtonStyle.qml @ import QtQuick.Controls 1.2 import QtQuick.Controls.Styles 1.2 Component { ButtonStyle { background: Rectangle { implicitWidth: 100 implicitHeight: 25 border.width: control.activeFocus ? 2 : 1 border.color: "#888" radius: 4 gradient: Gradient { GradientStop { position: 0 ; color: control.pressed ? "#ccc" : "#eee" } GradientStop { position: 1 ; color: control.pressed ? "#aaa" : "#ccc" } } } } } @ and then main.qml is the file which gets loaded first and contains your button and also it loads MyButtonStyle.qml as a Component main.qml. Afterwards it's id viz. mystyle is set to Button. Thus we have set the Style Component to the Button. @ import QtQuick 2.2 MyButtonStyle { id: mystyle } Button { text: "A button" style: mystyle } @ Hope this helps...
  • [solved]QQmlApplicationEngine: Moving from 5.2 to 5.3

    7
    0 Votes
    7 Posts
    3k Views
    M
    Thank you guys that was really helpful.
  • 0 Votes
    3 Posts
    780 Views
    B
    @ MouseArea { width: 400 height: 100 Rectangle { anchors.fill: parent color: "red" Text { text: "btn" } } onClicked: { console.log("hi I've been clicked") } } @ vs @ Rectangle { width: 400 height: 100 color: "red" Text { text: "btn" } MouseArea { anchors.fill: parent onClicked: { console.log("hi I've been clicked") } } } @
  • 0 Votes
    2 Posts
    644 Views
    SGaistS
    Hi and welcome to devnet, You should take a look at Qt's documentation examples and demos, they show pretty much all the basics you need.