[PR #219] [MERGED] QQuickPaintedItem support #250

Closed
opened 2026-05-05 11:21:39 -06:00 by gitea-mirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/qmlnet/qmlnet/pull/219
Author: @devmil
Created: 8/19/2020
Status: Merged
Merged: 12/1/2020
Merged by: @pauldotknopf

Base: developHead: feature/QQuickPaintedItem_support


📝 Commits (10+)

  • bf58cf1 Merge branch 'hotfix/0.10.1'
  • 663e05a Merge branch 'release/0.11.0'
  • bfbe3d4 First support for QQuickPaintedItem
  • f9e9eab Less string passing during drawing
  • 61893a6 Color string to id conversion is now an implementation detail of QmlNetPaintedItem
  • 9dd329a Adds Font metrics functionality
  • a893865 Adds DrawText overload with bounding rectangle
  • 334c42c Dont copy the actions on each draw but lock the vector
  • cb35ed9 Optional Text support for QmlNetPaintedItem (including preedit)
  • caa2fb0 Adds Flags to the DrawText (Rect) method

📊 Changes

15 files changed (+1824 additions, -17 deletions)

View changed files

📝 .gitignore (+3 -1)
📝 src/native/QmlNet (+1 -1)
📝 src/net/Qml.Net.Tests/Qml.Net.Tests.csproj (+1 -0)
📝 src/net/Qml.Net.Tests/Qml/BaseQmlTests.cs (+68 -12)
📝 src/net/Qml.Net.Tests/Qml/MvvmInteropBehaviorTests.cs (+0 -1)
src/net/Qml.Net.Tests/Qml/QmlNetQuickPaintedItemTests.cs (+709 -0)
📝 src/net/Qml.Net/Internal/DefaultCallbacks.cs (+2 -2)
📝 src/net/Qml.Net/Internal/Helpers.cs (+11 -0)
📝 src/net/Qml.Net/Internal/Interop.cs (+6 -0)
src/net/Qml.Net/NetQPainter.cs (+779 -0)
📝 src/net/Qml.Net/QCoreApplication.cs (+7 -0)
📝 src/net/Qml.Net/QGuiApplication.cs (+5 -0)
📝 src/net/Qml.Net/QQmlApplicationEngine.cs (+12 -0)
📝 src/net/Qml.Net/Qml.cs (+14 -0)
src/net/Qml.Net/QmlNetQuickPaintedItem.cs (+206 -0)

📄 Description

This PR adds QQuickPaintedItem support to Qml.Net.

I use this currently in a QML.Net based terminal application, so it seems to work.

The approach is:

  1. Qml.Net provides a new registered type: QuickItems
  2. Qml.Net provides a .Net base class for painted items: QmlNetPaintedItem
  3. Users create a subclass of QmlNetPaintedItem on .Net side and implement the paint() method
  4. The C++ side makes sure that the paint() call gets routed to the .Net class that can use the QPainter that is passed to do the actual drawing
  5. Qml.Net makes sure that all properties, methods and signals that the QmlNetPaintedItem derived type has are mirrored to QML just as they are with any other type that gets registeres with QML

QmlNetInnerWorkingsPaintedItem

Example usage:

import Qml.Net 1.0
// [...]
    TerminalQuickPaintedItem {
        id: terminalContent
        anchors.fill: parent
        anchors.margins: terminalMargins
// [...]
    }
public class TerminalQuickPaintedItem : QmlNetQuickPaintedItem
{
    public TerminalViewModel TerminalViewModel { get; set; }

    public override void Paint(NetQPainter painter)
    {
        //implement paint logic
    }
}

//[...]

Qml.Net.Qml.RegisterPaintedQuickItemType<TerminalQuickPaintedItem>(@namespace, versionMajor, versionMinor);

Solves #198


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/qmlnet/qmlnet/pull/219 **Author:** [@devmil](https://github.com/devmil) **Created:** 8/19/2020 **Status:** ✅ Merged **Merged:** 12/1/2020 **Merged by:** [@pauldotknopf](https://github.com/pauldotknopf) **Base:** `develop` ← **Head:** `feature/QQuickPaintedItem_support` --- ### 📝 Commits (10+) - [`bf58cf1`](https://github.com/qmlnet/qmlnet/commit/bf58cf1ac2f288582b63a969cc6860cceb46bb96) Merge branch 'hotfix/0.10.1' - [`663e05a`](https://github.com/qmlnet/qmlnet/commit/663e05ab2b5c1d871044fc339a57f9ac5fae61ba) Merge branch 'release/0.11.0' - [`bfbe3d4`](https://github.com/qmlnet/qmlnet/commit/bfbe3d462a21ada9ec898dd38e55dad799b75d2f) First support for QQuickPaintedItem - [`f9e9eab`](https://github.com/qmlnet/qmlnet/commit/f9e9eabb84ca8a5d08bf089089df2c7176f835e4) Less string passing during drawing - [`61893a6`](https://github.com/qmlnet/qmlnet/commit/61893a6b576679ed7dc698da383b849b3ac15233) Color string to id conversion is now an implementation detail of QmlNetPaintedItem - [`9dd329a`](https://github.com/qmlnet/qmlnet/commit/9dd329ae509471b636beed46f988a38424bd9203) Adds Font metrics functionality - [`a893865`](https://github.com/qmlnet/qmlnet/commit/a8938654d73cec31ee94478107e054b688d5f6a6) Adds DrawText overload with bounding rectangle - [`334c42c`](https://github.com/qmlnet/qmlnet/commit/334c42ca696c265dcaf0cbcd0894ab3946d24a38) Dont copy the actions on each draw but lock the vector - [`cb35ed9`](https://github.com/qmlnet/qmlnet/commit/cb35ed9b7e4a04e6c3abe5d5b145c1a595f00547) Optional Text support for QmlNetPaintedItem (including preedit) - [`caa2fb0`](https://github.com/qmlnet/qmlnet/commit/caa2fb011372e996b0494c159f54804039ead871) Adds Flags to the DrawText (Rect) method ### 📊 Changes **15 files changed** (+1824 additions, -17 deletions) <details> <summary>View changed files</summary> 📝 `.gitignore` (+3 -1) 📝 `src/native/QmlNet` (+1 -1) 📝 `src/net/Qml.Net.Tests/Qml.Net.Tests.csproj` (+1 -0) 📝 `src/net/Qml.Net.Tests/Qml/BaseQmlTests.cs` (+68 -12) 📝 `src/net/Qml.Net.Tests/Qml/MvvmInteropBehaviorTests.cs` (+0 -1) ➕ `src/net/Qml.Net.Tests/Qml/QmlNetQuickPaintedItemTests.cs` (+709 -0) 📝 `src/net/Qml.Net/Internal/DefaultCallbacks.cs` (+2 -2) 📝 `src/net/Qml.Net/Internal/Helpers.cs` (+11 -0) 📝 `src/net/Qml.Net/Internal/Interop.cs` (+6 -0) ➕ `src/net/Qml.Net/NetQPainter.cs` (+779 -0) 📝 `src/net/Qml.Net/QCoreApplication.cs` (+7 -0) 📝 `src/net/Qml.Net/QGuiApplication.cs` (+5 -0) 📝 `src/net/Qml.Net/QQmlApplicationEngine.cs` (+12 -0) 📝 `src/net/Qml.Net/Qml.cs` (+14 -0) ➕ `src/net/Qml.Net/QmlNetQuickPaintedItem.cs` (+206 -0) </details> ### 📄 Description This PR adds QQuickPaintedItem support to Qml.Net. I use this currently in a QML.Net based terminal application, so it seems to work. The approach is: 1. Qml.Net provides a new registered type: QuickItems 2. Qml.Net provides a .Net base class for painted items: QmlNetPaintedItem 3. Users create a subclass of QmlNetPaintedItem on .Net side and implement the paint() method 4. The C++ side makes sure that the paint() call gets routed to the .Net class that can use the QPainter that is passed to do the actual drawing 5. Qml.Net makes sure that all properties, methods and signals that the QmlNetPaintedItem derived type has are mirrored to QML just as they are with any other type that gets registeres with QML ![QmlNetInnerWorkingsPaintedItem](https://user-images.githubusercontent.com/6693130/95000356-5dc54080-05c0-11eb-9d2d-ebe24157b580.png) Example usage: ```QML import Qml.Net 1.0 // [...] TerminalQuickPaintedItem { id: terminalContent anchors.fill: parent anchors.margins: terminalMargins // [...] } ``` ```C# public class TerminalQuickPaintedItem : QmlNetQuickPaintedItem { public TerminalViewModel TerminalViewModel { get; set; } public override void Paint(NetQPainter painter) { //implement paint logic } } //[...] Qml.Net.Qml.RegisterPaintedQuickItemType<TerminalQuickPaintedItem>(@namespace, versionMajor, versionMinor); ``` Solves #198 --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
gitea-mirror 2026-05-05 11:21:39 -06:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: github-starred/qmlnet#250
No description provided.