Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Convert MFC dialogs to Qt?
Forum Updated to NodeBB v4.3 + New Features

Convert MFC dialogs to Qt?

Scheduled Pinned Locked Moved Solved General and Desktop
11 Posts 3 Posters 1.3k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dan203
    wrote on last edited by
    #1

    Does anyone know of a tool that can convert MFC resource dialogs to Qt .ui files? I found a few references to such tools existing but I can't actually find one.

    1 Reply Last reply
    0
    • Christian EhrlicherC Offline
      Christian EhrlicherC Offline
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      There is no such tool, you have to do it manually.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      2
      • mrjjM Offline
        mrjjM Offline
        mrjj
        Lifetime Qt Champion
        wrote on last edited by
        #3

        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
        }
        
        D 1 Reply Last reply
        0
        • mrjjM mrjj

          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
          }
          
          D Offline
          D Offline
          Dan203
          wrote on last edited by
          #4

          @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.

          mrjjM 1 Reply Last reply
          0
          • D Dan203

            @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.

            mrjjM Offline
            mrjjM Offline
            mrjj
            Lifetime Qt Champion
            wrote on last edited by mrjj
            #5

            @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 :)

            D 1 Reply Last reply
            0
            • mrjjM mrjj

              @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 :)

              D Offline
              D Offline
              Dan203
              wrote on last edited by
              #6

              @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…

              1a99334b-9f48-42a2-b548-330a91da3d0b-image.jpeg https://www.videoredo.com/en/images/v5_profiles.jpg

              1 Reply Last reply
              0
              • D Offline
                D Offline
                Dan203
                wrote on last edited by
                #7

                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.

                mrjjM 1 Reply Last reply
                0
                • D Dan203

                  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.

                  mrjjM Offline
                  mrjjM Offline
                  mrjj
                  Lifetime Qt Champion
                  wrote on last edited by mrjj
                  #8

                  @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

                  1 Reply Last reply
                  1
                  • D Offline
                    D Offline
                    Dan203
                    wrote on last edited by
                    #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

                    mrjjM 1 Reply Last reply
                    0
                    • D Dan203

                      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

                      mrjjM Offline
                      mrjjM Offline
                      mrjj
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Dan203

                      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.

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        Dan203
                        wrote on last edited by
                        #11

                        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.

                        1 Reply Last reply
                        0

                        • Login

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Categories
                        • Recent
                        • Tags
                        • Popular
                        • Users
                        • Groups
                        • Search
                        • Get Qt Extensions
                        • Unsolved