MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
{
QThread *thread = new QThread;
Worker *worker= new Worker();
worker->moveToThread(thread);
//init connections
thread->start();
}
< /code>
Worker Constructor: < /p>
Worker::Worker(QObject *parent) :
QObject(parent)
{
serial = new QSerialPort(this); //passing the parent, which should be the current thread
}
< /code>
NO -Kompilierfehler, aber wenn ich es ausführe, wirft es mir das aus: < /p>
QObject: Cannot create children for a parent that is in a different thread.
(Parent is QSerialPort(0x11bd1148), parent's thread is QThread(0x11bd2ef8), current thread is QThread(0x3e47b8)
< /code>
nämlich sagt mir, dass seriell < /code> als übergeordneter Haupt Thread und nicht den Thread, den ich erstellt habe, hat. < /p>
Das gleiche Ergebnis, wenn ich im Konstruktor nicht die Serie instanziiere, sondern im Hauptprozess, der ausgelöst wird, nachdem wir Thread-> start () < /code>: < /p>
genannt habenWorker::Worker(QObject *parent) :
QObject(parent)
{
}
Worker::doWork()
{
if(!serial)
serial= new QSerialPort(this);
//...
}
< /code>
Was fehlt mir?void Worker::send(const QByteArray &data)
{
serial->write(data);
if( serial->waitForBytesWritten(TIMEOUT) )
qDebug()
Befolgen[code]MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) { QThread *thread = new QThread; Worker *worker= new Worker();
worker->moveToThread(thread);
//init connections
thread->start(); } < /code>
Worker Constructor: < /p>
Worker::Worker(QObject *parent) : QObject(parent) { serial = new QSerialPort(this); //passing the parent, which should be the current thread } < /code>
NO -Kompilierfehler, aber wenn ich es ausführe, wirft es mir das aus: < /p>
QObject: Cannot create children for a parent that is in a different thread. (Parent is QSerialPort(0x11bd1148), parent's thread is QThread(0x11bd2ef8), current thread is QThread(0x3e47b8) < /code>
nämlich sagt mir, dass seriell < /code> als übergeordneter Haupt Thread und nicht den Thread, den ich erstellt habe, hat. < /p>
Das gleiche Ergebnis, wenn ich im Konstruktor nicht die Serie instanziiere, sondern im Hauptprozess, der ausgelöst wird, nachdem wir Thread-> start () < /code>: < /p>
genannt habenWorker::Worker(QObject *parent) : QObject(parent) { }
Worker::doWork() { if(!serial) serial= new QSerialPort(this);
Ich habe einen GeoDataFrame-Ereignisse, der nur Punktgeometrien enthält, und einen anderen GeoDataFrame-Straßen, der alle LineString-Geometrien enthält. Ich versuche, alle Punkte in Ereignissen am...
Ich versuche, ein einfaches Python -Skript in der Spyder IDE, v5.5.1, auszuführen, wie in Anaconda enthalten.
import pandas as pd
import seaborn as sns
import matplotlib.pyplot as plt
Ich erstelle eine kleine WPF -Anwendung zur Praxis, in der ich Daten mit dem Entitäts -Framework -Kern in eine MySQL -Datenbank einfügen und die Ergebnisse in einem anderen Fenster anzeigen möchte....
Ich erstelle eine kleine WPF -Anwendung zur Praxis, in der ich Daten mit dem Entitäts -Framework -Kern in eine MySQL -Datenbank einfügen und die Ergebnisse in einem anderen Fenster anzeigen möchte....