QDialogBox GUI makes a Framebuffer copy
-
Hello every one, I have a problem with QDialogBox after I implemented QThread into my application.
So what exactly is happening - after I try to open QDialogBox to open a file or save a file, my QDialogBox copy the appearance of the mainwindow with the same size and else.
-
Hello every one, I have a problem with QDialogBox after I implemented QThread into my application.
So what exactly is happening - after I try to open QDialogBox to open a file or save a file, my QDialogBox copy the appearance of the mainwindow with the same size and else.
@CptN3m0 said in QDialogBox GUI makes a Framebuffer copy:
after I implemented QThread into my application
Can you explain (better: show code) what exactly you changed?
-
@CptN3m0 said in QDialogBox GUI makes a Framebuffer copy:
after I implemented QThread into my application
Can you explain (better: show code) what exactly you changed?
@jsulm Hi,
I created a new class named "MyThread":
.h
#ifndef MYTHREAD_H #define MYTHREAD_H #include <QThread> #include <QString> class MyThread : public QThread { Q_OBJECT public: explicit MyThread(QString s); void run(); signals: void send(int); private: QString name; }; #endif // MYTHREAD_H.cpp
#include "mythread.h" #include <QDebug> #include <mainwindow.h> MyThread::MyThread(QString s) : name(s) { } void MyThread::run() { for(int i = 0; i <= 1;) { emit send(i); sleep(1); } }wrote an signal in mainwindow
MyThread *thread= new MyThread("A"); connect(thread, SIGNAL(send(int)), this, SLOT(update(int))); thread->start();and just show some info in console inside of
update(int) -
@jsulm Hi,
I created a new class named "MyThread":
.h
#ifndef MYTHREAD_H #define MYTHREAD_H #include <QThread> #include <QString> class MyThread : public QThread { Q_OBJECT public: explicit MyThread(QString s); void run(); signals: void send(int); private: QString name; }; #endif // MYTHREAD_H.cpp
#include "mythread.h" #include <QDebug> #include <mainwindow.h> MyThread::MyThread(QString s) : name(s) { } void MyThread::run() { for(int i = 0; i <= 1;) { emit send(i); sleep(1); } }wrote an signal in mainwindow
MyThread *thread= new MyThread("A"); connect(thread, SIGNAL(send(int)), this, SLOT(update(int))); thread->start();and just show some info in console inside of
update(int) -
@CptN3m0 And if you don't start the thread your app is working properly? I can't see how this thread would influence the GUI.
-
@jsulm can't check right now, how my application would work without this thread.
But mayber because I check if some button in my GUI was clicked or not?if(ui->pB_B->isChecked() == true || ui->pB_B_2->isChecked() == true){ // some code } -
@jsulm well.. I'm doing this in my thread.. this is also the problem, because I'm checking the state of some GUI elements?
-
@CptN3m0 You should not access any UI related classes from other threads than GUI thread. This is not supported.
-
Hi,
Use signals and slots to communicate your UI values to the thread.
-
Well, add two setters to your MyThread class, one for each boolean value that you want to check and connect them to your GUI.
-
Well, add two setters to your MyThread class, one for each boolean value that you want to check and connect them to your GUI.
-
Please show the complete code you are using for that part.