cast icon indicating copy to clipboard operation
cast copied to clipboard

Question: Qt event posting vs. signal-slot connection API image stream

Open MiragonMx opened this issue 10 months ago • 2 comments

I'm implementing a module for viewing the processed ultrasound images in a large pre-existing Qt and partly C application. In general, I've oriented myself mostly at the caster_qt example, while omitting unnecessary functionality and adapting to project conventions. Now I was wondering, whether there are specific reasons why the example uses the postEvent function so much (even referencing that in the comments/documentation). Couldn't this be implemented more 'Qt-esque' with signal-slot connections?

I've tried to read up on that and it seems possible to me (see, e.g., this discussion). Since there are multiple windows, core/gui separation etc. in the existing application, I think that might be easier to handle for the interaction between a module (similar to the Caster in the example) handling the initialization, connection and callback handling and a displaying module in a window with a graphsview subclass similar to the one in display.cpp. Specifically, this would be with a custom signal void sigNewProcImg(const void* pvImgData, int iWidth, int iHeight, int iBitsPerPixel, int iSizeInBytes); and a corresponding slot in the GraphicsView subclass.

I'm not super versed in Qt or graphics programming in general so I wanted to hear if the choice was more opinionated or if there are parts of this that I have overseen or misunderstood. I'd be very happy to get your insight on this!

MiragonMx avatar Mar 31 '25 15:03 MiragonMx

Since the API uses pure C callbacks, I wanted to limit the amount of globals/statics in the program, so posting an event to the static main window allowed for the best containment of code. You can feel free to modify and implement as you wish however.

clariusk avatar Mar 31 '25 15:03 clariusk

Thanks for the very quick reply! That answers my question, so as far as I'm concerned the issue can be closed, unless it should be kept open for reference (might be better suited for a discussions or wiki tab if that should be started..

MiragonMx avatar Apr 01 '25 07:04 MiragonMx