ich habe hier ein Problem wo ich einfach nicht weiter komme
Code: Alles auswählen
class MyWindow : public QMainWindow, public QThread{
public:
MyWindow()
:infoWidget(new QWidget()),connections(new QLabel()){
initLayout();
connections->setText("Empty");
setCentralWidget(infoWidget);
QThread::start();
}
protected:
void run(void){
for(int i = 0; i < 100; i++){
std::stringstream stream;
stream<<"connections : "<<i;
std::cout<<stream.str()<<std::endl;
connections->setText(stream.str().c_str());
}
}
void initLayout(void){
BorderLayout *layout = new BorderLayout;
layout->addWidget(connections,BorderLayout::East);
infoWidget->setLayout(layout);
}
private:
QWidget *infoWidget;
QLabel *connections;
};
QObject: Cannot create children for a parent that is in a different thread.
Wie könnte man das lösen ?