<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[How to update a Q3DScatter on MainWindow from a new thread?]]></title><description><![CDATA[<p dir="auto">Dear all,</p>
<p dir="auto">I wrote a programm with two Q3DScatter on the MainWindow. In the next step it is necessary to update the the Q3DScatter in an endless process till a certain button is pushed. Therefore I want to use a new thread, because otherweise it's not possible to push the button while the main thread is still running.<br />
But how is it possible to manipulate the QScatter by using a new thread?<br />
Below you can see the MainWindow declaration.</p>
<pre><code>MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui-&gt;setupUi(this);


    graph = new Q3DScatter();

    QWidget *container = QWidget::createWindowContainer(graph);

    graph2 = new Q3DScatter();

    QWidget *container2 = QWidget::createWindowContainer(graph2);


    ui-&gt;gridLayout-&gt;addWidget(container);
    ui-&gt;gridLayout_2-&gt;addWidget(container2);
}
</code></pre>
<p dir="auto">And there is another class for updating the scatter:</p>
<pre><code>scattermodifier *modifier = new scattermodifier(graph);

   scattermodifier2 *modifier_2 = new scattermodifier2(graph2);
</code></pre>
<p dir="auto">Could anybody give me a  hint how to solve the problem?</p>
<p dir="auto">Thanks a lot!</p>
<p dir="auto">Best regards,</p>
<p dir="auto">Timo</p>
]]></description><link>https://forum.qt.io/topic/79712/how-to-update-a-q3dscatter-on-mainwindow-from-a-new-thread</link><generator>RSS for Node</generator><lastBuildDate>Sun, 19 Jul 2026 10:00:51 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/79712.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 28 May 2017 18:25:39 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to How to update a Q3DScatter on MainWindow from a new thread? on Tue, 30 May 2017 04:12:21 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/timo_f">@<bdi>Timo_F</bdi></a> Well, you connect where you have access to both instances: the sender and the receiver. I guess you create myThread instance in MainWindow? In this case connect in MainWindow.</p>
]]></description><link>https://forum.qt.io/post/396154</link><guid isPermaLink="true">https://forum.qt.io/post/396154</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Tue, 30 May 2017 04:12:21 GMT</pubDate></item><item><title><![CDATA[Reply to How to update a Q3DScatter on MainWindow from a new thread? on Mon, 29 May 2017 17:51:01 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a>  Hm I read it, but where should I define the connect()?<br />
That's my header file and I also implemented the listen, which should be contacted by a second thread.<br />
I have no idea how it should be done.</p>
<pre><code>namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_pushButton_clicked();

    void on_pushButton_4_clicked();

    void on_pushButton_update_clicked();

    void on_pushButton_delete_clicked();

    void on_checkBox_stateChanged(int arg1);

    void on_radioButton_A_clicked();

    void on_radioButton_PS_clicked();

    void listen(QString a);


signals:


public:
    Ui::MainWindow *ui;
    QtDataVisualization::Q3DScatter * graph;
    QtDataVisualization::Q3DScatter * graph2;





};
</code></pre>
<p dir="auto">That is inside the thread class.</p>
<pre><code>class myThread : public QObject
{
    Q_OBJECT
public:
    explicit myThread(QObject *parent = 0);

signals:
    void mstart();

public slots:
};
</code></pre>
<p dir="auto">Thanks a lot.</p>
<p dir="auto">Kindly regards,<br />
Timo</p>
]]></description><link>https://forum.qt.io/post/396092</link><guid isPermaLink="true">https://forum.qt.io/post/396092</guid><dc:creator><![CDATA[Timo_F]]></dc:creator><pubDate>Mon, 29 May 2017 17:51:01 GMT</pubDate></item><item><title><![CDATA[Reply to How to update a Q3DScatter on MainWindow from a new thread? on Mon, 29 May 2017 11:47:35 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/timo_f">@<bdi>Timo_F</bdi></a> Did you actually read <a href="http://doc.qt.io/qt-5.8/signalsandslots.html" target="_blank" rel="noopener noreferrer nofollow ugc">http://doc.qt.io/qt-5.8/signalsandslots.html</a> ?<br />
Please read it first.<br />
Yes, you need to inherit QObject and add Q_OBJECT macro to your class.<br />
And you do not add mySignal() function, instead you add mySignal() signal:</p>
<pre><code>signals:
    void mySignal();</code></pre>
]]></description><link>https://forum.qt.io/post/396017</link><guid isPermaLink="true">https://forum.qt.io/post/396017</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 29 May 2017 11:47:35 GMT</pubDate></item><item><title><![CDATA[Reply to How to update a Q3DScatter on MainWindow from a new thread? on Mon, 29 May 2017 11:40:45 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a> ok I added the function mySignal() to the MainWindow. How can I start that function?<br />
Do I need to sub-class QObject? Sorry, but I never did that before. How do I use QObject::connect for MainWindow object?</p>
<p dir="auto">Thank you very much.</p>
]]></description><link>https://forum.qt.io/post/396016</link><guid isPermaLink="true">https://forum.qt.io/post/396016</guid><dc:creator><![CDATA[Timo_F]]></dc:creator><pubDate>Mon, 29 May 2017 11:40:45 GMT</pubDate></item><item><title><![CDATA[Reply to How to update a Q3DScatter on MainWindow from a new thread? on Mon, 29 May 2017 09:06:51 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a>  thanks!!<br />
No, I have a seperate vision-application, that is comunicating with Qt. The vision-app provides a set of points, that should be visualized in a Q3DScatter.</p>
]]></description><link>https://forum.qt.io/post/395987</link><guid isPermaLink="true">https://forum.qt.io/post/395987</guid><dc:creator><![CDATA[Timo_F]]></dc:creator><pubDate>Mon, 29 May 2017 09:06:51 GMT</pubDate></item><item><title><![CDATA[Reply to How to update a Q3DScatter on MainWindow from a new thread? on Mon, 29 May 2017 09:04:43 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/timo_f">@<bdi>Timo_F</bdi></a> Like any other signal. You can emit a signal at any time:</p>
<pre><code>emit mySignal();
</code></pre>
<p dir="auto">You are talking about processes, but I guess you mean threads?</p>
]]></description><link>https://forum.qt.io/post/395986</link><guid isPermaLink="true">https://forum.qt.io/post/395986</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 29 May 2017 09:04:43 GMT</pubDate></item><item><title><![CDATA[Reply to How to update a Q3DScatter on MainWindow from a new thread? on Mon, 29 May 2017 09:01:49 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/jsulm">@<bdi>jsulm</bdi></a>  thanks a lot. My sub-process should wait till data is provided by another process (via boost message queue)  and then  the mainwindow should be updated... how could I create a signal that is provided without a button is pushed or sth like that?</p>
]]></description><link>https://forum.qt.io/post/395984</link><guid isPermaLink="true">https://forum.qt.io/post/395984</guid><dc:creator><![CDATA[Timo_F]]></dc:creator><pubDate>Mon, 29 May 2017 09:01:49 GMT</pubDate></item><item><title><![CDATA[Reply to How to update a Q3DScatter on MainWindow from a new thread? on Mon, 29 May 2017 04:36:14 GMT]]></title><description><![CDATA[<p dir="auto"><a class="plugin-mentions-user plugin-mentions-a" href="/user/timo_f">@<bdi>Timo_F</bdi></a> Do not change UI from other threads! Never! This is not supported and will cause problems.<br />
For what you want to do just use QTimer, no need for an endless loop.<br />
If you still want to use endless loop in a thread then do not change the UI in this thread, but emit a signal instead. Connect a slot in your MainWindow to this signal and change the UI in this slot.</p>
]]></description><link>https://forum.qt.io/post/395932</link><guid isPermaLink="true">https://forum.qt.io/post/395932</guid><dc:creator><![CDATA[jsulm]]></dc:creator><pubDate>Mon, 29 May 2017 04:36:14 GMT</pubDate></item></channel></rss>