Results 1 to 5 of 5

Thread: Thread and QGIS

  1. #1
    Join Date
    Mar 2015
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Smile Thread and QGIS

    Hello,

    i'm currently working on a software that includes a mapping (using QGIS library). Mapping calculates every second different positions and makes a display on the map, resulting in monopolization of my main thread.
    The problem being that my main thread should be used for other functions ...

    I tried to use QProcess by creating two different programs (1 with the Carto, and 1 with the HMI) in an attempt to include the carto program in the other program, however, it is not possible to retrieve the widget carto ...

    I would like to know if you have any idea how I could achieve this, it would save me from having a much too slow program.
    Sorry if this is not clear and for my bad english.

    For information, I develop on Ubuntu 14.04 and I use Qt 4.6.8.

    Thank you in advance

  2. #2
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Thread and QGIS

    Not sure I understand the problem regarding "not possible to retrieve the widget carto"... When you use QProcess, it runs the programs with the arguments you specify in separate processes within the operating system. Your Qt app can then interact with the QProcess's by reading their stdout/stderr or even provide input to the external processes by writing to the QProcess using QProcess::write, which the external process can read as stdin...

    Can you try to explain again what your problem is?
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  3. #3
    Join Date
    Mar 2015
    Posts
    9
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Thread and QGIS

    Hi, thank you for your answer.

    My problem is that my main thread will draw all the time on the map and all other actions (ex : clicks boutton) will be slowed because of the frequency display.

  4. #4
    Join Date
    Dec 2009
    Location
    New Orleans, Louisiana
    Posts
    791
    Thanks
    13
    Thanked 153 Times in 150 Posts
    Qt products
    Qt5
    Platforms
    MacOS X

    Default Re: Thread and QGIS

    The drawing *must* be done on the main GUI thread, so you may have to adopt an approach where you update your data as frequently as you want, then have a QTimer that draws at some reasonable rate.
    I write the best type of code possible, code that I want to write, not code that someone tells me to write!

  5. #5
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: Thread and QGIS

    If the map itself is static, and the only thing you are changing is the markers you display on it, then you are probably wasting a huge amount of CPU updating the map when you should only be updating the markers.

    You could

    1) Convert the map to a pixmap and only update it when the user moves / zooms / etc.
    2) Display the markers in an overlay window
    3) Don't redraw the map so frequently (as jefftee said). What's reasonable? Once every second? Twice a second? A good design should be able to handle that.

Similar Threads

  1. QGIS in Qt
    By Vivek1982 in forum Newbie
    Replies: 3
    Last Post: 10th October 2014, 13:50
  2. Replies: 1
    Last Post: 25th October 2012, 16:10
  3. Replies: 1
    Last Post: 28th March 2012, 19:58
  4. Replies: 5
    Last Post: 22nd February 2011, 22:21
  5. QGIS shapefiles
    By Struja in forum Qt Programming
    Replies: 0
    Last Post: 15th July 2009, 14:36

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.