Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QDialogBox GUI makes a Framebuffer copy

QDialogBox GUI makes a Framebuffer copy

Scheduled Pinned Locked Moved Unsolved General and Desktop
c++
15 Posts 3 Posters 2.3k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CptN3m0
    wrote on last edited by
    #1

    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.

    jsulmJ 1 Reply Last reply
    0
    • C CptN3m0

      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.

      jsulmJ Offline
      jsulmJ Offline
      jsulm
      Lifetime Qt Champion
      wrote on last edited by
      #2

      @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?

      https://forum.qt.io/topic/113070/qt-code-of-conduct

      C 1 Reply Last reply
      0
      • jsulmJ jsulm

        @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?

        C Offline
        C Offline
        CptN3m0
        wrote on last edited by
        #3

        @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)
        
        jsulmJ 1 Reply Last reply
        0
        • C CptN3m0

          @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)
          
          jsulmJ Offline
          jsulmJ Offline
          jsulm
          Lifetime Qt Champion
          wrote on last edited by
          #4

          @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.

          https://forum.qt.io/topic/113070/qt-code-of-conduct

          C 1 Reply Last reply
          0
          • jsulmJ jsulm

            @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.

            C Offline
            C Offline
            CptN3m0
            wrote on last edited by
            #5

            @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
            }
            
            jsulmJ 1 Reply Last reply
            0
            • C CptN3m0

              @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
              }
              
              jsulmJ Offline
              jsulmJ Offline
              jsulm
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @CptN3m0 As long as you don't do this in your thread it shouldn't be a problem.

              https://forum.qt.io/topic/113070/qt-code-of-conduct

              C 1 Reply Last reply
              0
              • jsulmJ jsulm

                @CptN3m0 As long as you don't do this in your thread it shouldn't be a problem.

                C Offline
                C Offline
                CptN3m0
                wrote on last edited by
                #7

                @jsulm well.. I'm doing this in my thread.. this is also the problem, because I'm checking the state of some GUI elements?

                jsulmJ 1 Reply Last reply
                0
                • C CptN3m0

                  @jsulm well.. I'm doing this in my thread.. this is also the problem, because I'm checking the state of some GUI elements?

                  jsulmJ Offline
                  jsulmJ Offline
                  jsulm
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  @CptN3m0 You should not access any UI related classes from other threads than GUI thread. This is not supported.

                  https://forum.qt.io/topic/113070/qt-code-of-conduct

                  C 1 Reply Last reply
                  0
                  • jsulmJ jsulm

                    @CptN3m0 You should not access any UI related classes from other threads than GUI thread. This is not supported.

                    C Offline
                    C Offline
                    CptN3m0
                    wrote on last edited by
                    #9

                    @jsulm what should I do then, to get it working correct?

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Hi,

                      Use signals and slots to communicate your UI values to the thread.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      C 1 Reply Last reply
                      0
                      • SGaistS SGaist

                        Hi,

                        Use signals and slots to communicate your UI values to the thread.

                        C Offline
                        C Offline
                        CptN3m0
                        wrote on last edited by
                        #11

                        @SGaist Hi, can you show me a little example?

                        1 Reply Last reply
                        0
                        • SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #12

                          Well, add two setters to your MyThread class, one for each boolean value that you want to check and connect them to your GUI.

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          C 1 Reply Last reply
                          0
                          • SGaistS SGaist

                            Well, add two setters to your MyThread class, one for each boolean value that you want to check and connect them to your GUI.

                            C Offline
                            C Offline
                            CptN3m0
                            wrote on last edited by
                            #13
                            This post is deleted!
                            1 Reply Last reply
                            0
                            • C Offline
                              C Offline
                              CptN3m0
                              wrote on last edited by
                              #14

                              I check it out without thread, doenst help. Still the same issue.

                              1 Reply Last reply
                              0
                              • SGaistS Offline
                                SGaistS Offline
                                SGaist
                                Lifetime Qt Champion
                                wrote on last edited by
                                #15

                                Please show the complete code you are using for that part.

                                Interested in AI ? www.idiap.ch
                                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                                1 Reply Last reply
                                0

                                • Login

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • Users
                                • Groups
                                • Search
                                • Get Qt Extensions
                                • Unsolved