Search code examples
qtmigrationwxwidgets

Recommended guidelines on moving from wxWidget to QT


I have a project that uses the wxwidget toolkit (wxThread, wxString, wxEvent, wxDateTime, wxLog etc). I am in the process of moving over to QT.

I am a little daunted by the task, and thought its best to come in here to ask those that may have carried out such an operation before.

Do I:

  1. take a more measured approach (replace one class at a time - this may not be as straight forward as it sounds, as there are some dependencies between the classes)

  2. Simply dive in head first and rip the guts out and refactor everything in one go (Hmm, sounds painful ...)


Solution

  • I don't know WxWidgets, so I only have half of an answer:

    1. If not already done, try to separate out all the logic from the GUI operations before migrating to Qt. You could likely achieve this following Jeremy Miller's Presentation Patterns. It generally works well to wrap your domain classes in GUI classes. This allows you to work in the language of the domain. The wrapping class can then be used in communication with the GUI and essentially serves as an Adapter class. This makes testing lightweight and minimal.
    2. Avoid callbacks since Qt uses signals and slots. Where you would need to send a message, call a virtual function -- this will make it easy to test using Mocks / Fakes / Stubs and follows the open-closed principle, allowing for easy modification once in Qt.
    3. Once you have your GUI separated from the application logic, use QTestlib to confirm that you're seeing the correct messages (signals).
    4. Lastly, be careful with the differences between WxWidgets and Qt. I'm not sure what they are, but incorrect assumptions could easily eat away your time. Actually reading the docs, even on simple widgets, will inevitably save you time.