Results 1 to 2 of 2

Thread: Windows to Ubuntu migration using Qt

  1. #1
    Join Date
    Dec 2010
    Location
    Ottawa, On, Canada
    Posts
    11
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Windows to Ubuntu migration using Qt

    Good morning,

    I am migrating an application developed for Windows to Ubuntu using Qt-4.6. So far I am making good progress but there are two Windows functions that are giving me trouble.

    I have been using QWaitCondition objects to reproduce the behaviour of Windows events (CreateEvent(), SetEvent(), and WaitForSingleObject()). In Windows, for WaitForSingleObject(), if the time-out argument (dwMilliseconds) is zero, the function does not enter a wait state if the object (event) is not signalled; it always returns immediately. The returned value indicates whether the object has been signalled.

    I tried to reproduce this behaviour using QWaitCondition::wait() with time-out set to zero without success. The locked mutex is not released and the function always returns false indicating that the wait timed out. I could not find any description related to time-out set to zero either.

    What is the corresponding behaviour in Qt for WaitForSingleObject() using time-out set to zero?

    My second question is about QThread. Again, the migration is mostly working but I don't know how to reproduce the behaviour of Windows Sleep( 0).
    According to the documentation, a value of zero causes the thread to relinquish the remainder of its time slice to any other thread that is ready to run. If there are no other threads ready to run, the function returns immediately, and the thread continues execution.

    How is this behaviour reproduced using Qt? Do I simply use a sleep statement? In this case, what time value is used? The application is running live image processing and display.

    Thanks in advance
    Daniel

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Windows to Ubuntu migration using Qt

    Quote Originally Posted by ottawaDan View Post
    I have been using QWaitCondition objects to reproduce the behaviour of Windows events (CreateEvent(), SetEvent(), and WaitForSingleObject()). In Windows, for WaitForSingleObject(), if the time-out argument (dwMilliseconds) is zero, the function does not enter a wait state if the object (event) is not signalled; it always returns immediately. The returned value indicates whether the object has been signalled.

    I tried to reproduce this behaviour using QWaitCondition::wait() with time-out set to zero without success. The locked mutex is not released and the function always returns false indicating that the wait timed out. I could not find any description related to time-out set to zero either.

    What is the corresponding behaviour in Qt for WaitForSingleObject() using time-out set to zero?
    How about using QSemaphore with QSemaphore::tryAcquire() instead?

    How is this behaviour reproduced using Qt?
    You can't. Schedulling is managed by the operating system. If you use sleep(0) you thread will go to sleep regardless of whether there are other threads in the application at all.

    If I'm guessing correctly what you are trying to do then I'd suggest changing the design to use QtConcurrent::run() or do all the work in one thread with idle processing if required/useful.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. console output on windows and ubuntu
    By hannesvdc in forum Qt Programming
    Replies: 2
    Last Post: 11th December 2010, 22:43
  2. Windows to Mac Migration
    By davidpiedra in forum Qt Programming
    Replies: 0
    Last Post: 11th November 2010, 16:01
  3. QIcon not shown on Ubuntu, works on Windows
    By JPNaude in forum Qt Programming
    Replies: 3
    Last Post: 11th November 2010, 05:28
  4. Windows Migration Framework
    By raman_31181 in forum Qt-based Software
    Replies: 2
    Last Post: 28th September 2008, 21:41
  5. Migration from Qt3 to Qt4
    By mourad in forum Qt Programming
    Replies: 1
    Last Post: 13th May 2008, 19:10

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.