跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k 主題 77.6k 貼文
  • Qml Canvas Dashed/Dotted Lines

    qml qtquick canvas
    2
    0 評價
    2 貼文
    11k 瀏覽
    S
    I am curious to the response to this, as I had a similar need a few months back. I ended up doing a brute force drawing of the dashed line with the following Component, but would prefer to use patterns as the OP was trying to do. import QtQuick 2.4 Canvas { id: canvas anchors.fill: parent property real start_x: 0 property real start_y: 0 property real end_x: width property real end_y: height property bool dashed: true property real dash_length: 10 property real dash_space: 8 property real line_width: 2 property real stipple_length: (dash_length + dash_space) > 0 ? (dash_length + dash_space) : 16 property color draw_color: "white" onPaint: { // Get the drawing context var ctx = canvas.getContext('2d') // set line color ctx.strokeStyle = draw_color; ctx.lineWidth = line_width; ctx.beginPath(); if (!dashed) { ctx.moveTo(start_x,start_y); ctx.lineTo(end_x,end_y); } else { var dashLen = stipple_length; var dX = end_x - start_x; var dY = end_y - start_y; var dashes = Math.floor(Math.sqrt(dX * dX + dY * dY) / dashLen); if (dashes == 0) { dashes = 1; } var dash_to_length = dash_length/dashLen var space_to_length = 1 - dash_to_length var dashX = dX / dashes; var dashY = dY / dashes; var x1 = start_x; var y1 = start_y; ctx.moveTo(x1,y1); var q = 0; while (q++ < dashes) { x1 += dashX*dash_to_length; y1 += dashY*dash_to_length; ctx.lineTo(x1, y1); x1 += dashX*space_to_length; y1 += dashY*space_to_length; ctx.moveTo(x1, y1); } } ctx.stroke(); } }
  • Socketcan in QTQuick

    3
    0 評價
    3 貼文
    2k 瀏覽
    C
    Where you able to find a solution for that? I am trying to understand the CAN network with SocketCAN and QT and Yocto. Will you be able to help? - Thanks.
  • Commercial Desktop Applications Using Qt Quick?

    3
    0 評價
    3 貼文
    1k 瀏覽
    T
    @whereness Blizzard’s game launcher does use Qt Quick 2.
  • QML Designer Custom Properties

    11
    0 評價
    11 貼文
    5k 瀏覽
    T
    @RamK The specifics files define a custom property sheet. This is currently not documented, but you can have a look at the Qt Creator source code.
  • 此主題已被刪除!

    已鎖定
    1
    0 評價
    1 貼文
    23 瀏覽
    尚無回覆
  • Copy ListModel or complete ListView Component

    listview listmodel copy
    5
    0 評價
    5 貼文
    4k 瀏覽
    S
    Hmmm...okay, I think it works now. I will create "backup.qml" dynamically with Qt.createComponent() and createObject(root, {listModel: ListModel}). After that I access the property listModel in the created component, iterate over the current listModel which should be backuped and append that items in the listModel of the new-created component. At the end I push the new-created component on stack to be able to backup more than one "state" of the model.
  • Nested MultiPointTouchArea and MouseArea: grab and cancel

    multipointtouch mousearea
    1
    0 評價
    1 貼文
    2k 瀏覽
    尚無回覆
  • Best approach to organize a bunch of QML files

    5
    0 評價
    5 貼文
    4k 瀏覽
    G
    @gardiol I was facing the same problem once. It seems there doesn't exist a single standard / recommendation from QT on how to organize project's folders. So I came up with my own structure to suit my needs. Feel free to use it if you like. project |- src |- Classes // classes which are responsible for application's logic are here |- Helpers |- AppHelper.qml ..... |- Components // your custom global components are here |- Buttons |- TextButton |- Images |- TextButton.qml ..... |- Translations // translation files (if necessary for the project) |- es.ts |- es.qm |- Views // all major pieces of UI (divide it on as many pieces as u want) |- Header |- Images |- Components // your custom local components used only within "Header" view |- Views // all pieces of "Header" view |- InfoArea |- Images |- InfoArea.qml ..... |- Header.qml |- Main |- Footer |- Views.qml |- Windows |- About |- Images |- About.qml ..... |- main.qml // entry point of qml application |- bin |- project.pro I use Upper CamelCase notation for folder and file names, except for main.qml. As for putting all files into qt's resource file - also no problems at all. Just use relative paths on import within your qml files.
  • Pass custom object in signal from QML

    Solved qml signal & slot
    4
    0 評價
    4 貼文
    3k 瀏覽
    p3c0P
    @yeckel Right. Forgot to mention it here. You can mark the post as solved
  • 0 評價
    1 貼文
    976 瀏覽
    尚無回覆
  • 0 評價
    2 貼文
    2k 瀏覽
    CharbyC
    Has any one experienced the same problem ? Any idea of a possible workaround ? Thanks for your help.
  • Changing view's model crashes at some point

    bug treeview listview crash
    2
    0 評價
    2 貼文
    1k 瀏覽
    P
    Nevermind I found a solution: QQmlApplicationEngine::setObjectOwnership(MY_OBJECT*, QQmlApplicationEngine::CppOwnership); It's important to set this whenever returning a pointer in a Q_INVOKABLE function or else it might get garbage collected apparently.
  • Manually update a Calendar

    3
    0 評價
    3 貼文
    964 瀏覽
    W
    Hi @p3c0 ! Thanks for your reply. This code is just a test, I didn't make any "real" UI, that's why I used Component.onCompleted. But I'll try your solution and come back :) It seems the Calendar isn't updated because the delegate doesn't use any property (because of the property binding). If I declare a fake bool property in CalendarView and I use this trick : (beware, it's very very very ugly) // main.qml [...] onNoteAdded: { calendarView.fakeProp = !calendarView.fakeProp } // CalendarView.qml [...] // delegate Label { text: if (fakeProp || !fakeProp ) styleData.date.getDate() + " " + model.getNotesCount(styleData.date) } It works but...omg it's just...horrible. Unfortunately, the model.getNotesCount() function used above isn't a property but just a Q_INVOKABLE. ('model' subclasses QObject and acts like a wrapper around a QMap) I think I must create a property that makes sense in this context. Sorry for my bad english
  • Wrong Device Pixel Ratio (DPR) when using multiple screens with different DPR

    screen device d
    1
    0 評價
    1 貼文
    597 瀏覽
    尚無回覆
  • 0 評價
    1 貼文
    774 瀏覽
    尚無回覆
  • Qml and javascript files in resource (qrc), how to import js in qml ?

    11
    0 評價
    11 貼文
    24k 瀏覽
    A
    Try to put ".js" in the alias like: <file alias="componentCreator.js">qml/CC/componentCreation.js</file>
  • Make TreeView flickable

    tree view flickable 5.5
    0
    0 評價
    0 貼文
    703 瀏覽
    尚無回覆
  • 0 評價
    4 貼文
    2k 瀏覽
    X
    color: "transparent" works correctly for me in an ApplicationWindow on Linux.
  • [Request] TreeView C++ model to qml example

    treeview tree view example qml
    4
    0 評價
    4 貼文
    7k 瀏覽
    p3c0P
    @Pheelbert Yes missed the mentioning of data() here. You're Welcome :-) Happy Coding.
  • Properties and signals

    2
    0 評價
    2 貼文
    555 瀏覽
    p3c0P
    Every signal has a corresponding signal handler by deafult in QML. What is your second question ?