[GH-ISSUE #188] Accessing Qt classes from c# #121

Closed
opened 2026-05-05 11:05:42 -06:00 by gitea-mirror · 2 comments
Owner

Originally created by @Blquinn on GitHub (Mar 12, 2020).
Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/188

Hello, thanks for the great lib!

I have an application where I need to do some image manipulation. It is a CT scan viewer / CAD style program. Therefore I need to be able to manipulate images, create overlays, zoom and all sorts of other stuff. My preference would be to do this in c# code and just have the qml call functions in my c# code.

Is it possible to have the qml layer simply present an image that lives in my c# code and not just load an image with src in the image component? I could probably use a hack and continuously write the image to disk and reload it in qml, but I'd prefer to do something more similar to what you can do in native c++.

Thank you for any input!

Originally created by @Blquinn on GitHub (Mar 12, 2020). Original GitHub issue: https://github.com/qmlnet/qmlnet/issues/188 Hello, thanks for the great lib! I have an application where I need to do some image manipulation. It is a CT scan viewer / CAD style program. Therefore I need to be able to manipulate images, create overlays, zoom and all sorts of other stuff. My preference would be to do this in c# code and just have the qml call functions in my c# code. Is it possible to have the qml layer simply present an image that lives in my c# code and not just load an image with `src` in the image component? I could probably use a hack and continuously write the image to disk and reload it in qml, but I'd prefer to do something more similar to what you can do in native c++. Thank you for any input!
Author
Owner

@pauldotknopf commented on GitHub (Mar 12, 2020):

You can expose the image as an array of bytes.

Or, create a pointer in C#, manage memory in C# (overlay, etc), and expose it via QML (this would require some C++ though).

<!-- gh-comment-id:598297480 --> @pauldotknopf commented on GitHub (Mar 12, 2020): You can expose the image as an array of bytes. Or, create a pointer in C#, manage memory in C# (overlay, etc), and expose it via QML (this would require some C++ though).
Author
Owner

@Blquinn commented on GitHub (Mar 12, 2020):

Thanks for the quick response :)

I don't mind writing a bit of c++ if it means I can do most of my heavy logic in c#.

So I could probably use bitmaps (hopefully some higher level library in c#) and access its data directly in qml? How would I access that image data in qml?

Sorry, I know relatively little about c# <> c++ interop and how qml fits into the equation.

<!-- gh-comment-id:598301746 --> @Blquinn commented on GitHub (Mar 12, 2020): Thanks for the quick response :) I don't mind writing a bit of c++ if it means I can do most of my heavy logic in c#. So I could probably use bitmaps (hopefully some higher level library in c#) and access its data directly in qml? How would I access that image data in qml? Sorry, I know relatively little about c# <> c++ interop and how qml fits into the equation.
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#121
No description provided.