Skip to content

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k Topics 77.6k Posts
  • keyboard does not show up

    Unsolved
    6
    0 Votes
    6 Posts
    708 Views
    Aleksey_KA
    So the problem was obvious because of following lines: #ifdef Q_OS_LINUX qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); #endif Changed to #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) qputenv("QT_IM_MODULE", QByteArray("qtvirtualkeyboard")); #endif And voila: Android keyboard works! :)
  • Shortcuts & QtQuick.Controls

    Unsolved
    1
    1 Votes
    1 Posts
    198 Views
    No one has replied
  • How to implement TextInput drag and drop

    Unsolved qml textedit
    2
    0 Votes
    2 Posts
    757 Views
    fcarneyF
    You are trying to do 2 things that require the same actions. Drag and drop is not built into the TextInput object. So you need to learn how drag and drop works. Next, since you need to be able to change the mode of your TextInput you need to control when a selection can occur. Say for instance if text is selected that you do NOT want selection motion to work. Then use the selectedText property to control the selectByMouse property: selectByMouse: selectedText <= 0 I do not know if this will lock you into that mode. So you may need a way to back out of a selection. What happens when you click the text again? Does it deselect the text?
  • How to avoid text over flow in TextEdit

    Solved
    2
    0 Votes
    2 Posts
    235 Views
    ODБOïO
    @Rajashekara-V hi you can set clip: true on the parent rectangle see also https://wiki.qt.io/Flickable_Wrapped_TextEdit
  • 0 Votes
    2 Posts
    796 Views
    jeanmilostJ
    So as nobody answered this question, I found a workaround which seems to resolve my issue. I changed the stroke width from 1 to 1.5. However this unfortunately doesn't explain what happened here, and why the ShapePath object behaves this way. I have my own idea about that: I think it's a kind of pen alignment, as in GDI+ (https://docs.microsoft.com/en-us/windows/win32/api/gdiplusenums/ne-gdiplusenums-penalignment), however I found absolutely no way to configure that. So below is my solution, which works correctly in all situations on my side: import QtQuick 2.15 import QtQuick.Window 2.15 import QtQuick.Controls 2.15 import QtQuick.Shapes 1.15 import QtGraphicalEffects 1.15 import QtQuick.Templates 2.15 as T /** * Dashed border *@author JMR */ T.Control { // advanced properties property real m_StrokeWidth: 1.5 property int m_Radius: 5 property string m_FillColor: "transparent" property string m_StrokeColor: "#bac1db" /** * Background rectangle */ Rectangle { // common properties anchors.fill: parent color: m_FillColor radius: m_Radius /** * Dashed outline shape */ Shape { // common properties id: shDashedBorder anchors.fill: parent anchors.margins: 0 //layer.enabled: true //layer.samples: 8 smooth: true clip: true /** * Dashed outline shape path */ ShapePath { // common properties fillColor: "transparent" strokeColor: m_StrokeColor strokeWidth: m_StrokeWidth strokeStyle: ShapePath.DashLine dashPattern: [5, 5] startX: m_Radius startY: 0 // path commands PathLine {x: shDashedBorder.width - m_Radius; y: 0;} PathQuad {x: shDashedBorder.width; y: m_Radius; controlX: shDashedBorder.width; controlY: 0;} PathLine {x: shDashedBorder.width; y: shDashedBorder.height - m_Radius;} PathQuad {x: shDashedBorder.width - m_Radius; y: shDashedBorder.height; controlX: shDashedBorder.width; controlY: shDashedBorder.height;} PathLine {x: m_Radius; y: shDashedBorder.height;} PathQuad {x: 0; y: shDashedBorder.height - m_Radius; controlX: 0; controlY: shDashedBorder.height;} PathLine {x: 0; y: m_Radius;} PathQuad {x: m_Radius; y: 0; controlX: 0; controlY: 0;} } } } }
  • Python with Qt Quick: Qt Quick emulation layer crashed. (Line 1:)

    Unsolved
    4
    2 Votes
    4 Posts
    971 Views
    S
    I have not found the solution but I have created a ticket: https://bugreports.qt.io/browse/QTCREATORBUG-25277
  • I get an error when refactoring connect.

    Unsolved
    2
    0 Votes
    2 Posts
    219 Views
    J.HilkJ
    @w-tkm what version of Qt do you use ? the error signal was deprecated and errorOccured was introduced. This was made due to the fact that error is not only a signal but also a regular function of QAbstractSocket. to use an overload in the new connect syntax requires the use of complicated casting, or the use of the qOverload macro https://doc.qt.io/qt-5/qtglobal.html#qOverload
  • How QML determines default font.pixelSize

    Solved
    2
    0 Votes
    2 Posts
    1k Views
    SeeLookS
    OK. I've got it.... auto pixelSize = qApp.font().pointSizeF() / 72.0 * qApp->primaryScreen()->logicalDotsPerInch();
  • Not able to handle Signals

    Solved
    3
    0 Votes
    3 Posts
    999 Views
    P
    @LeLev Thanks for your quick response, it works
  • 0 Votes
    6 Posts
    1k Views
    mbruelM
    So thanks to @LeLev who gave me a solution using a ColumnLayout, here is from where I was starting ListView{ anchors.fill: parent spacing: 10 model: 5 delegate: Column { width: parent.width height: exp.checked ? r.height + v.height + spacing : r.height spacing: 10 Rectangle{ id: r width: parent.width height: 50 color: "grey" CheckBox{ id:exp anchors.right: parent.right text: "expand " + index } } ListView { id: v model: 10 spacing: 1 clip : true height: contentHeight width: parent.width visible: exp.checked delegate: Rectangle{ height: 30 width: parent.width color: "lightblue" } } } } The goal was to dynamically load the second ListView in Loader so the page loads much faster. Here is @LeLev solution using a ColumnLayout: // 2.: Solution with a ColumnLayout Component{ id:view ListView { model: 10 spacing: 1 clip : true height: contentHeight delegate: Rectangle{ height: 30 width: parent.width color: "lightblue" } } } ListView{ anchors.fill: parent spacing: 10 model: 5 delegate: ColumnLayout{ height: exp.checked ? 50 + l.item.contentHeight : 50 width: root.width spacing: 1 Rectangle{ Layout.fillHeight: true Layout.fillWidth: true Layout.preferredHeight: 50 Layout.maximumHeight: 50 color: "grey" CheckBox{ id:exp anchors.right: parent.right text: "expand " + index onCheckedChanged: { l.sourceComponent = checked ? view : undefined } } } Loader{ id:l Layout.fillHeight: sourceComponent != undefined Layout.fillWidth: true // Layout.preferredHeight: sourceComponent != undefined ? 100 : 0 } } } and finally after a break and fighting with Column, it is also working without a Layout :) // 3.: Solution with a Column Component{ id:view ListView { model: 10 spacing: 1 clip : true height: contentHeight width: root.width delegate: Rectangle{ height: 30 width: parent.width color: "lightblue" } } } ListView{ anchors.fill: parent spacing: 10 model: 5 delegate: Column{ width: parent.width height: exp.checked ? r.height + l.item.height + spacing : r.height spacing: 10 Rectangle{ id: r width: parent.width height: 50 color: "grey" CheckBox{ id:exp anchors.right: parent.right text: "expand " + index onCheckedChanged: { l.sourceComponent = checked ? view : undefined } } } Loader{ id:l } } }
  • QML Button invisible on some systems

    Solved
    2
    0 Votes
    2 Posts
    301 Views
    O
    Ok. Finally I managed to workaround the behavior. Thanks to a user that gave me the tip via PM. I replaced the Button by a Rectangle with MouseArea.
  • Change color to BusyIndicator

    Unsolved
    15
    0 Votes
    15 Posts
    6k Views
    T
    Thank you very!
  • Getting notified when parent transformation changed

    Moved Unsolved
    1
    0 Votes
    1 Posts
    194 Views
    No one has replied
  • qml button clicked not triggered in *.qml file

    Solved
    3
    0 Votes
    3 Posts
    790 Views
    J
    Thank you , This solved the issue
  • Accessing QAbstractItemModel fields in QML

    Solved
    5
    0 Votes
    5 Posts
    997 Views
    ODБOïO
    @LeLev said in Accessing QAbstractItemModel fields in QML: To me it looks like i'm doing something wrong about QModelIndex creation, because if i pass the QModelIndex directly from qml to c++ like this : indeed this was the problem, instead of passing styleData.row and styleData.column to my Q_Invokable method i can pass styleData.index itemDelegate: Text { color: myUaModel.getSubActiveByIndex(styleData.index) ? "green" : "blue" } Q_INVOKABLE bool getSubActiveByIndex(QModelIndex ind){ bool isSub = false; if(!ind.isValid()) return isSub; auto item = static_cast<TreeItem *>(ind.internalPointer()); isSub = item->data(7).toBool(); return isSub; }
  • Problem integrating qt quick project with qt widgets project.

    Unsolved
    2
    0 Votes
    2 Posts
    343 Views
    KillerSmathK
    Hey @saumayd, welcome to Qt Forum. Where are you exporting the instance of object gmap to the qml ? [ERROR]: qrc:/maps/main.qml:26: ReferenceError: gmap is not defined Connections{ target: gmap onGetLat : mapmarker.center.latitude = lat } Are you passing the object to the qml context by calling setProperty before of line: view->setSource(QUrl("/maps/main.qml")); ? #include <QQmlContext> ... Gmap *gmap = new Gmap(this); // wherever you're creating the instance of object gmap ... QQmlContext *ctxt = view->rootContext(); ctxt->setContextProperty("gmap", gmap); // the property gmap is refered to gmap object in c++ view->setSource(QUrl("/maps/main.qml")); Read more: https://doc.qt.io/qt-5/qtqml-cppintegration-overview.html https://doc.qt.io/qt-5/qtqml-cppintegration-contextproperties.html
  • crazy frameworks integration.... and I'm stuck

    Solved
    7
    0 Votes
    7 Posts
    2k Views
    Stanislav SilnickiS
    @doomdi Hi! The code is slightly outdated, so some errors may appear due to its legacy nature (initial post is 3+ y.o.). I highly discourage you to go this way of USB-Android integration if you're missing deep understanding at least one of listed items: Java, JNI, USB stack, libusb, linux ioctl stuff, C++/Qt, Android SDK, pthreads. As the initial post suggests, its a CRAZY integration, so it should be depricated. I did it initially for curiosity and this solution wasn't used in any production environment. I wish I could help you, but my current occupation doesn't allow this happen these days, sorry.
  • This topic is deleted!

    Solved
    5
    0 Votes
    5 Posts
    88 Views
  • Problems of QAbstractListModel

    Unsolved
    2
    0 Votes
    2 Posts
    279 Views
    raven-worxR
    @Munkhtamir QML support QAbstractItemModel instances. For this to fully support you need to implement roleNames() method in your model and map context variable names to your item roles. See this example.
  • Signal in QML becomes undefined

    Solved
    3
    0 Votes
    3 Posts
    935 Views
    SietseAchteropS
    @GrecKo Thanks, solved! I missed that the arguments are the signals. That's what you get when you google for answers instead of properly reading the documentation.... Regards, Sietse