Results 1 to 4 of 4

Thread: converting Windows dialog resources to ui

  1. #1
    Join Date
    Apr 2008
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Question converting Windows dialog resources to ui

    Hi. We are considering switching an existing MFC based application to QT. While there are migration classes, to do it right we are planning to rewrite the application. However, it seems that there should be a way to convert our existing dialog resources to UI files. (I know the UI files would have to then be edited, but it seems like a conversion utility would save a lot of tedious initial layout.)

    I'm new to QT and can't seem to find the answer to this. I saw references to a "knut" utility, but it doesn't seem to have been updated since QT3. Is there something in the "visual studio integration" that would help? (I haven't seen that plugin yet since we have not yet decided to purchase QT. There seems to be little documentation for the "visual studio integration" which is probably good-- an indication that it is simple...)

    Thanks.
    Last edited by Thor28; 10th April 2008 at 05:47.

  2. #2
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: converting Windows dialog resources to ui

    The Visual Studio Integration package is simply a plugin written for VS that allows Designer to be user to draw UI's from scratch, it knows nothing about existing win32 resource files.

    I've never personally played with MFC.
    Are your ui resource files just standard win32 type resource following this kind of format? :
    Qt Code:
    1. IDD_ABOUTPAGE DIALOGEX 0, 0, 270, 160
    2. STYLE DS_SETFONT | DS_MODALFRAME | WS_POPUP | WS_CAPTION | WS_SYSMENU
    3. CAPTION "About"
    4. FONT 8, "MS Sans Serif", 0, 0, 0x0
    5. BEGIN
    6. ICON xxxxICON,IDC_xxxxICON,10,10,20,20,SS_CENTERIMAGE
    7. CONTROL "xxx",
    8. IDC_STATIC,"Static",SS_LEFTNOWORDWRAP | WS_GROUP,38,10,
    9. 166,11
    10. CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,38,23,218,1
    11. LTEXT "Program Version",IDC_STATIC,38,30,111,8
    12. LTEXT "Unknown",IDC_PROGRAMVERSION,156,30,100,8,0,WS_EX_RIGHT
    13. LTEXT "xxx Version",IDC_STATIC,38,42,111,8
    14. LTEXT "Unknown",IDC_xxx_VERSION,215,42,41,8,0,WS_EX_RIGHT
    15. LTEXT "xxx Release Date",IDC_STATIC,38,54,110,8
    16. LTEXT "Unknown",IDC_xxx_DATE3,167,54,89,8,0,WS_EX_RIGHT
    17. LTEXT "Patch Number",IDC_STATIC,38,66,111,8
    18. LTEXT "Unknown",IDC_PATCH,215,66,41,8,0,WS_EX_RIGHT
    19. CONTROL "",IDC_STATIC,"Static",SS_ETCHEDFRAME,38,78,218,1
    To copy to clipboard, switch view to plain text mode 

    If so, then I don't think it would be too difficult to write a utility to translate this into .ui files for Qt.
    The problem with the .rc files are that there's no one to one match on the items, there are string table definitions stored in .rc files as well. So you'd need to decide what to do with those as well, you could create an xml fragment and stick each discreet xml string table into the qt resource file. I can think plain strings can reside in a qt resource file you could also just dump all strings in there without modification.

    Also, keep in mind that you'd only have a base and you'd need to attach all your signals and slots, etc. Don't try to mimic the MFC way of doing things, I've seen people do this in the past and they end up hurting their brains. Realise that you need to rewrite most of your code into Qt equivalents and this will take time even if you have an auto port mechanism of some kind.
    Last edited by stevey; 21st April 2008 at 06:10.

  3. #3
    Join Date
    Mar 2006
    Posts
    140
    Thanks
    8
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: converting Windows dialog resources to ui

    Oh, something else the VS integration module does too is provide extra template project wizards and make it easier to globally switch between installed versions of Qt with minimal fuss.

  4. #4
    Join Date
    Apr 2008
    Posts
    8
    Thanks
    1
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: converting Windows dialog resources to ui

    Yes, the resource files are just standard win32 resource files like your example.

    I started down a path of building a utility to translate them, but then stopped thinking that it was so obvious that it must already exist. However, after searching around, I haven't found anything.

    I agree with your comment about rewriting into true QT code. My thinking was just to save the tedium of the initial layout. From there, I can use the designer. But it seems like I could get widget type, approximate placement, and main properties. From there, I can use the designer for layouts, buddies, signals/slots, other properties, etc., etc.

Similar Threads

  1. Replies: 2
    Last Post: 5th February 2007, 17:42
  2. converting unix exe to windows binary
    By deekayt in forum General Programming
    Replies: 2
    Last Post: 17th September 2006, 01:00
  3. dialog box
    By Bahar in forum Qt Programming
    Replies: 3
    Last Post: 31st January 2006, 14:52

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.