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. QThread and Error Access violation
Forum Updated to NodeBB v4.3 + New Features

QThread and Error Access violation

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 3.8k 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.
  • SGaistS Offline
    SGaistS Offline
    SGaist
    Lifetime Qt Champion
    wrote on last edited by
    #4

    You can't call a function from another class.

    Also, you have a signature mismatch between your header and implementation.

    What exactly are you trying to achieve ?

    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
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #5

      [quote author="SGaist" date="1407412316"]You can't call a function from another class.

      Also, you have a signature mismatch between your header and implementation.

      What exactly are you trying to achieve ?
      [/quote]

      Where is my mismatch can u show me?
      I want to change my tabWidget status from disable to enable after Thread processing...

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

        @
        namespace Ui {
        class MainWindow;
        }

        class MainWindow : public QMainWindow
        {
        Q_OBJECT

        public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
        public:
        void _send(QString _title, QString _message); << here
        }; @

        @
        void MyThread::run()
        {
        //Run my function
        _send(); << there
        }
        @

        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
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #7

          [quote author="SGaist" date="1407442699"]@
          namespace Ui {
          class MainWindow;
          }

          class MainWindow : public QMainWindow
          {
          Q_OBJECT

          public:
          explicit MainWindow(QWidget *parent = 0);
          ~MainWindow();
          public:
          void _send(QString _title, QString _message); << here
          }; @

          @
          void MyThread::run()
          {
          //Run my function
          _send(); << there
          }
          @

          [/quote]

          Hi again...

          I Chaged to

          @
          public:
          void _send();
          @

          and

          @
          void MainWindow::_send()

          {

          ui->tabWidget->setDisabled(false);

          };
          @

          and

          @
          void MyThread::run()
          {
          //Run my function
          //MainWindow::_send();

          MainWindow *II;
              II->_send();
          

          }
          @

          but not working !
          Error :

          @
          QObject::connect: No such slot MainWindow::_send() in ..\untitled15\mainwindow.cpp:40
          QObject::connect: (receiver name: 'MainWindow')
          @

          1 Reply Last reply
          0
          • M Offline
            M Offline
            msue
            wrote on last edited by
            #8

            try to change "public" into "public slots" before your send function.

            1 Reply Last reply
            0
            • ? Offline
              ? Offline
              A Former User
              wrote on last edited by
              #9

              [quote author="msue" date="1407481533"]try to change "public" into "public slots" before your send function.[/quote]

              Unfortunately ...
              The program has unexpectedly finished.
              ..\untitled15.exe crashed

              :(

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

                That's normal, MainWindow *ll is uninitialized.

                Anyway, you should not access MainWindow from your thread, just emit the signal you connected earlier.

                Also it's seems you are new to C++, I'd recommend getting a good book about it

                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
                • ? Offline
                  ? Offline
                  A Former User
                  wrote on last edited by
                  #11

                  [quote author="SGaist" date="1407483129"]That's normal, MainWindow *ll is uninitialized.

                  Anyway, you should not access MainWindow from your thread, just emit the signal you connected earlier.

                  Also it's seems you are new to C++, I'd recommend getting a good book about it[/quote]

                  Can you show me a good document or book about this question ?!
                  I mean how to update GUI in Thread process.

                  Thank you.

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

                    Qt's own documentation and examples e.g. the Mandelbrot example

                    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
                    • ? Offline
                      ? Offline
                      A Former User
                      wrote on last edited by
                      #13

                      [quote author="SGaist" date="1407484062"]Qt's own documentation and examples e.g. the Mandelbrot example[/quote]

                      Thank you for your helping... i try to read it :)

                      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