Note that there are some explanatory texts on larger screens.

plurals
  1. POProducer Accessing GUI outside GUI thread using service Pattern
    primarykey
    data
    text
    <p>My <code>Producer</code>(<em>which is running on a different thread</em>) needs access to <code>QDesktopWidget</code>, some QWidget, it also needs to work with <code>QPixmap</code>. So I designing the polling like this.</p> <p>Producer, Consumer, Transmitter are <code>boost::thread</code>. This is how I've planned.</p> <p>I've a <code>device::Service</code> class that is an <code>QObject</code> and lives in GUI thread. It is the base of all Service Classes. There is <code>device::PixmapService</code> that inherits <code>device::Service</code></p> <p>There is a method with the follwoing signature, that is called by <code>Producer</code> Thread. <code>ProxyTray&lt;QImage, device::PixmapService&gt; device::PixmapService::requestPixmap()</code> </p> <p><code>requestPixmap()</code> creates a tray <code>ProxyTray&lt;QImage, device::PixmapService&gt; blankTray</code><br /> and emit a <code>this-&gt;pixmapRequestedSignal(tray)</code> and returns the same <code>tray</code> immedietly.</p> <p><code>device::PixmapService::pixmapRequestedSlot</code> gets the request with Qt's Signal-Slot Mechanism. and resolves the tray by <code>tray.resolve(image)</code>.</p> <p>In the mean time Producer waits by doing. </p> <pre><code>while(!tray.released()); QImage image = tray.data(); </code></pre> <p>Is the design Okay ? Would It even work ? Am I reinventing some Wheel ?</p> <pre><code>template &lt;typename T, typename Manipulator&gt; class ProxyTray: public AbstractProxyTray{ friend class Manipulator; private: T _data; public: ProxyTray(); public: T&amp; data() const; ~ProxyTray(); private: void resolve(T&amp; data); }; class AbstractProxyTray{ private: bool _busy; public: AbstractProxyTray(); public: bool released() const;//returns !_busy virtual ~AbstractProxyTray() = 0; }; </code></pre> <p>also I need to write a copy con for the ProxyTray. and copying should be okay cause tray will be holding Qt types that is based on <code>QSharedData</code> which implements <code>copy on write</code>.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload