Convert MFC dialogs to Qt?
-
There is no such tool, you have to do it manually.
-
Hi
How many Dialogs do you have?
If such tool exsisted, it would have a hard time to guess where to add Qt layouts
which you really want to to be cross platform / cross resolution.That said, you could write a small text parser to extract the controls from the
RC file and create a start UI file. However, manual tweaking would be needed.ErrorDialog DIALOG 10, 10, 300, 110 <<<< dialog size STYLE WS_POPUP | WS_BORDER CAPTION "Error!" << title { CTEXT "Select One:", 1, 10, 10, 280, 12 <<<< QLabel PUSHBUTTON "&Retry", 2, 75, 30, 60, 12 <<< QPushButton PUSHBUTTON "&Abort", 3, 75, 50, 60, 12 PUSHBUTTON "&Ignore", 4, 75, 80, 60, 12 } -
Hi
How many Dialogs do you have?
If such tool exsisted, it would have a hard time to guess where to add Qt layouts
which you really want to to be cross platform / cross resolution.That said, you could write a small text parser to extract the controls from the
RC file and create a start UI file. However, manual tweaking would be needed.ErrorDialog DIALOG 10, 10, 300, 110 <<<< dialog size STYLE WS_POPUP | WS_BORDER CAPTION "Error!" << title { CTEXT "Select One:", 1, 10, 10, 280, 12 <<<< QLabel PUSHBUTTON "&Retry", 2, 75, 30, 60, 12 <<< QPushButton PUSHBUTTON "&Abort", 3, 75, 50, 60, 12 PUSHBUTTON "&Ignore", 4, 75, 80, 60, 12 }@mrjj said in Convert MFC dialogs to Qt?:
Hi
How many Dialogs do you have?
If such tool exsisted, it would have a hard time to guess where to add Qt layouts
which you really want to to be cross platform / cross resolution.That said, you could write a small text parser to extract the controls from the
RC file and create a start UI file. However, manual tweaking would be needed.ErrorDialog DIALOG 10, 10, 300, 110 <<<< dialog size STYLE WS_POPUP | WS_BORDER CAPTION "Error!" << title { CTEXT "Select One:", 1, 10, 10, 280, 12 <<<< QLabel PUSHBUTTON "&Retry", 2, 75, 30, 60, 12 <<< QPushButton PUSHBUTTON "&Abort", 3, 75, 50, 60, 12 PUSHBUTTON "&Ignore", 4, 75, 80, 60, 12 }Over a hundred.
Something that just imported the controls and named them properly would be a huge time saver. Even if I had to fix the layouts after the fact. The prospect of converting all these dialogs manually is daunting.
-
@mrjj said in Convert MFC dialogs to Qt?:
Hi
How many Dialogs do you have?
If such tool exsisted, it would have a hard time to guess where to add Qt layouts
which you really want to to be cross platform / cross resolution.That said, you could write a small text parser to extract the controls from the
RC file and create a start UI file. However, manual tweaking would be needed.ErrorDialog DIALOG 10, 10, 300, 110 <<<< dialog size STYLE WS_POPUP | WS_BORDER CAPTION "Error!" << title { CTEXT "Select One:", 1, 10, 10, 280, 12 <<<< QLabel PUSHBUTTON "&Retry", 2, 75, 30, 60, 12 <<< QPushButton PUSHBUTTON "&Abort", 3, 75, 50, 60, 12 PUSHBUTTON "&Ignore", 4, 75, 80, 60, 12 }Over a hundred.
Something that just imported the controls and named them properly would be a huge time saver. Even if I had to fix the layouts after the fact. The prospect of converting all these dialogs manually is daunting.
@Dan203
Hi
well i once help one here in forum in chat with such task.
His boss was paranoid so he could not post in the forum.For 100 dialogs, i agree, its worth 1 day to make the parser to get
a base UI file.What took most editing is how values from Dialog are read.
we wrapped some of the GetDlgItemXXX function to work with Qt Widgets
but some of the code had to be rewritten to make the Dialogs actually save / load data.Then there is the ListBox type. For many use cases the QListWidget works good but
Qt also offers models and views allowing easy data sharing so might be worth considering.Also regarding icons and such. Qt uses its own resource system so that is not a straight conversion.
Can you post one of the more complex dialog rc's ?
just to see. not used MFC in decades :) -
@Dan203
Hi
well i once help one here in forum in chat with such task.
His boss was paranoid so he could not post in the forum.For 100 dialogs, i agree, its worth 1 day to make the parser to get
a base UI file.What took most editing is how values from Dialog are read.
we wrapped some of the GetDlgItemXXX function to work with Qt Widgets
but some of the code had to be rewritten to make the Dialogs actually save / load data.Then there is the ListBox type. For many use cases the QListWidget works good but
Qt also offers models and views allowing easy data sharing so might be worth considering.Also regarding icons and such. Qt uses its own resource system so that is not a straight conversion.
Can you post one of the more complex dialog rc's ?
just to see. not used MFC in decades :)@mrjj said in Convert MFC dialogs to Qt?:
@Dan203
Hi
well i once help one here in forum in chat with such task.
His boss was paranoid so he could not post in the forum.For 100 dialogs, i agree, its worth 1 day to make the parser to get
a base UI file.What took most editing is how values from Dialog are read.
we wrapped some of the GetDlgItemXXX function to work with Qt Widgets
but some of the code had to be rewritten to make the Dialogs actually save / load data.Then there is the ListBox type. For many use cases the QListWidget works good but
Qt also offers models and views allowing easy data sharing so might be worth considering.Also regarding icons and such. Qt uses its own resource system so that is not a straight conversion.
Can you post one of the more complex dialog rc's ?
just to see. not used MFC in decades :)I can’t post any code, but the product is VideoReDo. Here is a screenshot of one of the dialogs I'm actually working on right now…
-
If nothing like this exists I might have to roll my own because doing this one by one from scratch is going to take forever.
@Dan203
Hi
Thank you. ok that is complex enough so that even some help, would well help.
Even just getting the Dialog window with all Widgets correctly name and with correct text should be a
speed up.Well the only tool i ever saw was
https://forum.qt.io/topic/94736/free-utility-to-convert-visual-studio-rc-file-to-qt-ui
But seems gone now.writing the parser is not that bad as we don't need high performance as such so we can use Qts split function to easily get most of the data.
VideoReDo, the commercial product ? Cool.
But looking it over. I think you are also looking at some total rewrite like for the DVD template editor as that screams for a custom widget.
So you are product owner and its time to port it to Qt ?Btw, i would start by scanning all RC files to see what is really being used.
The spec is not small
https://docs.microsoft.com/en-us/windows/win32/menurc/resource-definition-statements
but you might just need to support a handfull to get good results.UPDATE: looking around i found this
https://github.com/papyrussolution/OpenPapyrus/blob/master/Src/Tools/RcToUI.cpp
It does seem to convert RC To UI but i didn't test it as no RC to run it on :9 -
Thanks. I tried that tool and it does seem to work but it's got some flaws. Is the source you posted the same as that tool? If so I could probably just modify it to do what I want.
Yes VideoReDo the commercial product is what I'm working on. I am one of two developers who have been working on it for almost 20 years now. We're porting to Qt in hopes that eventually we can release a Mac version, but also because we like some of the UI flexibility that Qt offers compared to MFC. Our current code has a LOT of custom controls that I'm going to have to try to recreate in Qt so this is not a quick project. Compressing 20 years of code into a single project is a big task. :o
-
Thanks. I tried that tool and it does seem to work but it's got some flaws. Is the source you posted the same as that tool? If so I could probably just modify it to do what I want.
Yes VideoReDo the commercial product is what I'm working on. I am one of two developers who have been working on it for almost 20 years now. We're porting to Qt in hopes that eventually we can release a Mac version, but also because we like some of the UI flexibility that Qt offers compared to MFC. Our current code has a LOT of custom controls that I'm going to have to try to recreate in Qt so this is not a quick project. Compressing 20 years of code into a single project is a big task. :o
Hi
I don't know if that "Sprezzatura RCtoUI.exe" is the same as that from the source code.
or if it's even good, but could be a start.Well after 20 years. it's almost a family member :)
I think using Qt will turn out great. But yes, if you have many special controls then its
most likely huge projects. Not to mention that parts that have to be rewritten to use signals and slot.I wish you good luck.
-
I've started working on my own converter. The exe pointed to had too many limitations and the source code you linked to was so far off from my own coding style that it was going to take longer to figure out what it was doing than to just start over. Parsing the RC file and outputting XML is relatively simple, it's all just deciding which MFC controls and options map to which Qt widgets and options. If it works well maybe I'll release it to the community.