Results 1 to 2 of 2

Thread: Porting old Win32-based Application to Multi-OS capable Qt4 app

  1. #1
    Join Date
    Feb 2008
    Location
    Honolulu, HI
    Posts
    21
    Thanks
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question Porting old Win32-based Application to Multi-OS capable Qt4 app

    Hi people,

    I've been given the task to port a relatively complex Win32 MFC based application to Qt4 which is supposed to be able to run on both Linux (32/64-bit) and Win32. I personally have never programmed under Windows and therefore have trouble identifying possible improvements that I could do instead of copying the old code as far as I can.

    The application will drive (or presently drives) a robot. We want to get better control over the timing, integrate OpenGL simulation/visualization, and a networked client. The current implementation has a shared memory segment, and multiple threads. Most of the constants interesting to the robot (e.g. gear ratios, etc.) are "#define"s, and the SHM is implemented as a bunch of structures accumulated in one large structure and accessed via pointer like this:
    Qt Code:
    1. m_pSharedData=::MapViewOfFile(m_hMap, FILE_MAP_WRITE, 0, 0, 0);
    To copy to clipboard, switch view to plain text mode 

    Now I wonder if anyone here has some good tips in porting the software to Qt4. It is supposed to have a GUI interface. In terms of Software Design, does it make sense to separate the GUI functions (e.g. QApplication) from the actual drivers/low-level programming? Because in the current version, the event called from a, say, button, directly interacts with the electronics. In my opinion, this leads to the fact that the control code is distributed all over the code base and right now it's pretty hard to discern what function does what. Would it be clearer if I created some "robot" class that contains all the driving code, etc.?

    I am really open to suggestions and if Qt has a really cool class that does exactly what I want or provides means to make life so much easier without me having to re-invent the wheel, I would be very thankful. For example, I've read that there is something called QtConcurrent, which seems to be an easier choice that QThread, but I don't know...

    Thank you very much in advance.

    Stephan

  2. #2
    Join Date
    Jul 2009
    Location
    Enschede, Netherlands
    Posts
    462
    Thanked 69 Times in 67 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Porting old Win32-based Application to Multi-OS capable Qt4 app

    Quote Originally Posted by sfabel View Post
    In terms of Software Design, does it make sense to separate the GUI functions (e.g. QApplication) from the actual drivers/low-level programming?
    In practically all cases I'm aware of: Yes. It's always wise to separate out code that provides GUI functionality from the actual data logic, which is also done in the Model/View framework Qt provides. Aside from that, you could choose to redesign your user interface. If the application has the driving logic and the GUI code in the same place, you end up rewriting functional parts of your code while you only have to tackle the GUI. The other way around, you will have to work in your GUI code where it only involves data logic. Worst of all is going to be when you have to build a command line client. In my opinion you should approach every GUI application as a command line program with a graphic shell.


    Quote Originally Posted by sfabel View Post
    For example, I've read that there is something called QtConcurrent, which seems to be an easier choice that QThread, but I don't know...
    Indeed. I have the impression that the QtConcurrent classes work best when you have a lot of queueable tasks. You say that you want to gain more control over threading. In that case I think you should go for QThread and the other threading primitives, rather than QtConcurrent. Remember that you can only have one GUI thread in Qt.
    Horse sense is the thing that keeps horses from betting on people. --W.C. Fields

    Ask Smart Questions

  3. The following user says thank you to franz for this useful post:

    sfabel (2nd November 2009)

Similar Threads

  1. Replies: 0
    Last Post: 10th April 2009, 15:28
  2. Porting application from Linux to Win32
    By giusepped in forum Qt Programming
    Replies: 11
    Last Post: 2nd November 2008, 14:23

Tags for this Thread

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.