跳到內容

QML and Qt Quick

Looking for The Bling Thing(tm)? Post here!
20.1k 主題 77.7k 貼文
  • How to make a QQuickItem which will route mouse events to other QuickItem?

    Unsolved
    1
    0 評價
    1 貼文
    234 瀏覽
    尚無回覆
  • Change QML Screen from C++ thread

    已移動 Unsolved
    8
    0 評價
    8 貼文
    670 瀏覽
    Pablo J. RoginaP
    @JaviRodriguez I'd suggest to go through the documentation referred before again. Pay attention to the C++ signal and how that signal is handled in QML
  • Passing an Array of Objects from QML to C++

    Unsolved
    5
    0 評價
    5 貼文
    535 瀏覽
    DuBuD
    Wow, QVariantList with QVariantMap as contained variants works. Thanks a lot!
  • Replicating Microsoft's Acrylic

    Unsolved
    3
    0 評價
    3 貼文
    2k 瀏覽
    LorenDBL
    @Markkyboy: the problem with your implementation is that it is missing the blur effect. I did some fooling around recently and came up with this: import QtQuick 2.12 import QtQuick.Window 2.12 import QtQuick.Controls 2.12 import QtGraphicalEffects 1.0 Window { id: root color: "white" visible: true width: 640 height: 480 title: qsTr("Hello World") Image { id: img source: "qrc:/msofttest.png" anchors.fill: parent fillMode: Image.PreserveAspectCrop Rectangle { id: rect color: "white" opacity: 0.6 anchors.left: parent.left anchors.top: parent.top width: parent.width height: parent.height * 0.6 } ShaderEffectSource { id: ses anchors.centerIn: rect width: rect.width height: rect.height sourceItem: img sourceRect: Qt.rect(x, y, width, height) } GaussianBlur { source: ses anchors.fill: ses radius: 64 samples: 1 + radius * 2 // as per Qt docs } } } which produces: [image: adf59ebf-a904-42c1-bc81-2df508509764.png] (msofttest.png is the first image under "Acrylic Blend Types" in the Windows docs.) Using a different image produces a similar effect. Here I show an Acrylic-esque rectangle in the middle of the image using the following Rectangle instead of the one used earlier: Rectangle { id: rect color: "white" opacity: 0.4 anchors.centerIn: parent height: parent.height / 2 width: height } [image: 97528199-990c-4d1d-ad91-821584e43c6d.png] This gives me something that I can go off of to create in-app Acrylic. However, I'm still not sure how to do what I really wanted to do: use Acrylic as the app's background (this site has some screenshots of what I'd like to do, although it's XAML instead of QML). (I realize that I may not have clearly stated that I wanted the window background in Acrylic; I've updated my first post to be more specific.)
  • Access a StackView from a different QML file

    Solved qml export access module
    3
    0 評價
    3 貼文
    2k 瀏覽
    LorenDBL
    @sierdzio setting an alias for the StackView and then calling root.stack.push worked for me. Thanks!
  • Add data points to Map with MapItemView from C++

    Unsolved
    1
    0 評價
    1 貼文
    203 瀏覽
    尚無回覆
  • Get notified that object gonna be destroyed

    Unsolved
    4
    0 評價
    4 貼文
    1k 瀏覽
    JonBJ
    @morte If I understand correctly: I don't know what myObject is. But if you want to be notified of Banner's destruction you are supposed to slot onto Banner::destroyed() rather than myObject::destroyed(), if that is what you are doing.
  • StackView icon on Android

    Solved
    18
    0 評價
    18 貼文
    2k 瀏覽
    B
    @KroMignon said in StackView icon on Android: Perhaps you should use pictures or try with fontawesome? If it doesn't work with fonts, then I'll do it. @LorenDB . Could you please send me your StackView sample apk? Ill try to deploy it on problem devices. I reproduce this bug from Linux host. Prev tests was from Win 10. Now this looks like a problem with the devices OS. But it is very strange that with two at once..
  • ScrollView with empty TextArea

    Solved
    3
    0 評價
    3 貼文
    652 瀏覽
    F
    @LeLev Thank you very much! This worked flawlessly!
  • Animation using

    Unsolved
    6
    0 評價
    6 貼文
    624 瀏覽
    raven-worxR
    @qcoderpro ah my fault, sry. The y property declaration is on the same line, oversaw that
  • How to implement “Snap While Dragging” behavior in QML?

    Unsolved
    1
    0 評價
    1 貼文
    476 瀏覽
    尚無回覆
  • Looking for Slider with value update text

    Solved
    4
    0 評價
    4 貼文
    805 瀏覽
    ODБOïO
    @RobM https://doc.qt.io/qt-5/qtqml-cppintegration-data.html https://doc.qt.io/qt-5/qml-qtquick-controls2-slider.html#value-prop
  • MenuBar: display shortcut in QuickControls2

    Solved
    7
    0 評價
    7 貼文
    2k 瀏覽
    alex_spataruA
    Elaborating on the answers provided so far, I came up with the following solution: Create a QML file named CustomMenuItem.qml with the following code: import QtQuick 2.12 import QtQuick.Layouts 1.12 import QtQuick.Controls 2.12 MenuItem { id: root property alias sequence: _shortcut.sequence property bool indicatorVisible: root.icon.source.length > 0 || root.checkable Shortcut { id: _shortcut enabled: root.enabled onActivated: root.triggered() } contentItem: RowLayout { spacing: 0 width: root.width opacity: root.enabled ? 1 : 0.5 Item { width: root.indicatorVisible ? root.indicator.width + 4 : 0 } Label { text: root.text Layout.fillWidth: true elide: Label.ElideRight verticalAlignment: Qt.AlignVCenter } Item { Layout.fillWidth: true } Label { text: _shortcut.nativeText verticalAlignment: Qt.AlignVCenter } } } You can now use this item in your MenuBar as follows: MenuBar { Menu { title: qsTr("File") CustomMenuItem { sequence: StandardKey.Open text: qsTr("Select JSON file") + "..." } // Rest of code... (which I still haven't done) } } Screenshot: [image: ce000837-512e-4c36-98c8-d5a98d502987.png]
  • Invalid property assignment error in DLL but not QT creator

    已移動 Unsolved
    21
    0 評價
    21 貼文
    4k 瀏覽
    L
    @JKSH Well, progress in that I'm getting a new error "Cannot load library D:\Dev\UnityProjects\QT experiment\Assets\Plugins\QtQuick.2\qtquick2plugin.dll: The specified module could not be found" that dll is present at that exact location though Edit: Dependency walker shows it needs QT5Quick.dll, QT5Core etc... but those are all in its parent folder as produced by windeployqt
  • See any (or selected) items from other QML file (Form Editor)

    Unsolved
    7
    0 評價
    7 貼文
    651 瀏覽
    ekkescornerE
    @BD9a good luck
  • Component.onDestruction() causing segfault on closing applicaton

    Unsolved
    1
    0 評價
    1 貼文
    275 瀏覽
    尚無回覆
  • clarification on debugging QML

    Solved
    12
    0 評價
    12 貼文
    2k 瀏覽
    mzimmersM
    I discovered my error: I hadn't enabled QML debugging in the run settings for my project. (The documentation does say to do this, though it's kind of subtle.) Now I can break and examine variables. Thanks to all who looked at this.
  • Delete cookies of QML WebView

    已移動 Unsolved
    5
    0 評價
    5 貼文
    523 瀏覽
    Q
    I agree about the Javascript usage to delete cookies but when used in QML we have to access an element by "id" which in our case has to be QML WebView component id which inturn doesn't have any "cookies" property as opposed to Javascript Document Object. Hence i am failiing to implement any method to delete cookies. Am i missing on to something here (P.S: i never learnt JS and could gather these info from other forum solutions) ? Thanks
  • Qml TableView scrollbar

    Unsolved
    1
    0 評價
    1 貼文
    202 瀏覽
    尚無回覆
  • TableView with different delegates for its columns (QtQuick 2.15)

    Solved
    4
    0 評價
    4 貼文
    930 瀏覽
    SeDiS
    @SeDi For posterity, here's my working solution: delegate: Rectangle { width: childrenRect.width height: childrenRect.height Loader { sourceComponent: { switch(columnNo) { case 0: return firstDelegate; case 1: return secondDelegate; // ... default: return etcDelegate; } } } Component { id: firstDelegate Rectangle { width: childrenRect.width height: childrenRect.height color: "lightgray" Text { width: contentWidth + contentHeight height: contentHeight * 1.1 text: "first" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } } } Component { id: secondDelegate Rectangle { width: childrenRect.width height: childrenRect.height color: "yellow" Text { width: contentWidth + contentHeight height: contentHeight * 1.1 text: "second" verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } } } Component { id: etcDelegate Rectangle { width: childrenRect.width height: childrenRect.height color: "lightgreen" Text { width: contentWidth + contentHeight height: contentHeight * 1.1 text: foodName verticalAlignment: Text.AlignVCenter horizontalAlignment: Text.AlignHCenter } } } } To provide the columnNo role I had to do some work in my QAbstractTableModel. The roles enum in the header: class LogTableModel : public QAbstractTableModel { enum Role { DisplayRole = Qt::DisplayRole, DecorationRole = Qt::DecorationRole, StatusTipRole = Qt::StatusTipRole, //whatever... ColumnNoRole = Qt::UserRole+5 // or wherever it suits ... In data(...) I have implemented: QVariant LogTableModel::data(const QModelIndex &index, int role) const { if (index.isValid()) { switch(role) { case DisplayRole: return QVariant::fromValue(m_columns.at(index.column())->at(index.row())); case ColumnNoRole: return QVariant::fromValue(index.column()); ... roleNames() must also know it: QHash<int, QByteArray> LogTableModel::roleNames() const { QHash<int, QByteArray> roles; roles[DisplayRole] = "display"; roles[ColumnNoRole] = "columnNo"; ...