Using an MFC custom control from Qt
-
Well I didn't want to "just try it" as that could be the "wrong" way to proceed.
What's the recommended approach for hosting an MFC CWND derived window with a QWidget? Surely this must have come up before?
@Perdrix
https://forum.qt.io/topic/76525/cwnd-to-qwidgetSeparately, I don't know whether it's relevant but you may wish to look through https://docs.huihoo.com/qt/solutions/4/qtwinmigrate/winmigrate-walkthrough.html
-
Well I didn't want to "just try it" as that could be the "wrong" way to proceed.
What's the recommended approach for hosting an MFC CWND derived window with a QWidget? Surely this must have come up before?
@Perdrix said in Using an MFC custom control from Qt:
What's the recommended approach for hosting an MFC CWND derived window with a QWidget? Surely this must have come up before?
MFC and Qt are quite different frameworks and combining them is challenging. I don't have the experience to do it "correctly"; I'm not sure if anyone in this forum has that experience.
Thank you @JonB for providing links to what others have tried before. The source code for the Qt/MFC Migration Framework used by the walkthrough can be found at https://github.com/qtproject/qt-solutions/tree/master/qtwinmigrate . Unfortunately, it is no longer maintained so there is currently no officially-supported way to merge CWND and QWidget.
-
@Perdrix said in Using an MFC custom control from Qt:
What's the recommended approach for hosting an MFC CWND derived window with a QWidget? Surely this must have come up before?
MFC and Qt are quite different frameworks and combining them is challenging. I don't have the experience to do it "correctly"; I'm not sure if anyone in this forum has that experience.
Thank you @JonB for providing links to what others have tried before. The source code for the Qt/MFC Migration Framework used by the walkthrough can be found at https://github.com/qtproject/qt-solutions/tree/master/qtwinmigrate . Unfortunately, it is no longer maintained so there is currently no officially-supported way to merge CWND and QWidget.
I'm using qmfcapp and qwinwidget as they seem to be the only way to go.
I'm frankly quite shocked that you don't support those anymore - this must be a very common requirement for everyone who's converting their code to Qt!
I'm also a bit surprised that there's no expertise on porting to Qt here either ...
David
-
Just want to add to what @JKSH said above (.. they are quite different frameworks):
I used MFC and Visual C++ for almost 20 years before waking up to Qt and initially tried to port some code over, however all the MFC macros like message maps etc I could just toss and same for MVC stuff, so the only type of code that I did port was CString juggling (CString and QString are probably the most similar in vein parts of their respective frameworks).
-
Hi
What does this complex MFC custom control do ?
Mixing MFC and Qt might end up being a bigger job than to recreate
this control in Qt. -
One of them is a class derived from this: https://www.codeproject.com/articles/555/wndimage-control.
It adds mouse tracking, hit-testing, wheel zooming and "4-corners" mode that zooms into the four corners of the image.
With four corners not enabled:
https://www.codeproject.com/articles/555/wndimage-control
With four corners enabled:
The image is populated from an internally calculated windows bitmap (BITMAPINFO) derived from a 32bit floating point representation of an image. We'd obviously need to have a non-Windows in storage bitmap representation (maybe a Pixmap?) that could be built dynamically from our internal representation.
David
-
Hi
The https://doc.qt.io/qt-5/graphicsview.html
would give panning / zooming and and mouse tracking for (almost) free.is the 4 zoom area like a lens effect that zoom the area while you can pan the image around or is it more static ?
-
The four corner stuff is static ...
I'll take another look at the graphicsview control. I thought that was for managing lots of items within a scene, not for handling a single image.
Thanks
David@Perdrix
Hi
Well its also good to have many items but can also be
used for a single item like an image