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. Threads
Forum Updated to NodeBB v4.3 + New Features

Threads

Scheduled Pinned Locked Moved General and Desktop
10 Posts 6 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.
  • S Offline
    S Offline
    shirisha
    wrote on last edited by
    #1

    hi sir,
    please tell me how to use threads in qt very urgent..

    1 Reply Last reply
    0
    • IamSumitI Offline
      IamSumitI Offline
      IamSumit
      wrote on last edited by
      #2

      HI
      "Go":http://lmgtfy.com/?q=QThread

      Be Cute

      1 Reply Last reply
      0
      • JKSHJ Offline
        JKSHJ Offline
        JKSH
        Moderators
        wrote on last edited by
        #3

        There are many different ways to use threads in Qt. Here is an overview:

        • http://qt-project.org/doc/qt-5/threads-technologies.html

        Qt Doc Search for browsers: forum.qt.io/topic/35616/web-browser-extension-for-improved-doc-searches

        1 Reply Last reply
        0
        • S Offline
          S Offline
          shirisha
          wrote on last edited by
          #4

          hi sir..
          I have seen threads in net but am not able understand hoe to use ...after all search i cme to knw writing a thred like this.

          Mainwindow .cpp

          QThread *thread = new QThread(this);
          thread->start();
          connect(thread,Signal(started()),this,Slot(SerialportRead()));

          void MainWindow::SerialportRead()
          {
          //perform the serial port coomunication reading operation();

          }

          In this way i have created the thread ,but am unable to receive any response.Please help me ..

          1 Reply Last reply
          0
          • mrdebugM Offline
            mrdebugM Offline
            mrdebug
            wrote on last edited by
            #5

            Hi area 51, please have a look at this project
            http://kde-apps.org/content/show.php/QtComPort?content=142378
            you can see how I can read and manage data from serial port.

            Need programmers to hire?
            www.labcsp.com
            www.denisgottardello.it
            GMT+1
            Skype: mrdebug

            1 Reply Last reply
            0
            • P Offline
              P Offline
              poorBob
              wrote on last edited by
              #6

              I really, truly recommend this site to get idea of Qt threads:
              "http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/":http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation/

              best regards,
              poorBob

              1 Reply Last reply
              0
              • S Offline
                S Offline
                shirisha
                wrote on last edited by
                #7

                hi sir,

                     When i use the threads , am unable to activate the widgets ...
                
                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  shirisha
                  wrote on last edited by
                  #8

                  my code is :

                  #include "mainwindow.h"
                  #include "ui_mainwindow.h"
                  #include<QThread>
                  #include <QPushButton>
                  #include <QDebug>
                  #include <QTimer>
                  QThread *mthread ;
                  QTimer *mtimer ;
                  MainWindow::MainWindow(QWidget *parent) :
                  QMainWindow(parent),
                  ui(new Ui::MainWindow)
                  {
                  ui->setupUi(this);
                  ui->pushButton_color1->setAutoFillBackground(true);
                  ui->pushButton_color2->setAutoFillBackground(true);
                  ui->pushButton_color1->setStyleSheet("background-color : rgb(0, 255, 0)");

                     mtimer = new QTimer(this);
                     mthread  = new QThread(this);
                  
                     connect(mthread,SIGNAL(started()),this,SLOT(ReadData()));
                     connect(mtimer,SIGNAL(timeout()),this,SLOT(TimerData()));
                     mtimer->start(100);
                  

                  }

                  void MainWindow::ReadData()
                  {
                  while(1)
                  {
                  Serial();
                  }
                  }

                  void MainWindow::Serial()
                  {

                  for(int i=0;i<5;i++)
                      {
                          qDebug()<<"BBB:" <<i;
                      }
                  ui->pushButton_color2->setStyleSheet("background-color : rgb(0, 255, 0)");
                  

                  }

                  void MainWindow::TimerData()
                  {
                  mtimer->stop();
                  mthread->start();

                  }
                  MainWindow::~MainWindow()
                  {
                  delete ui;
                  }

                  on intialy one button is geting coloured, but when i place the other button in threads that is not geting color ,please help me.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    Sam
                    wrote on last edited by
                    #9

                    A small example of threading is provided "here":http://qt-project.org/forums/viewthread/26067

                    have a look at the last entry.

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      shirisha
                      wrote on last edited by
                      #10

                      Hi sir,

                           how to  write a sample program on threads ..so that it should display on gui..My problem is am able to get the data on Application output window, but unable to see on gui ..please help me sir..
                      
                      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