Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt WebKit
  4. For loop in button for sending url freeze app

For loop in button for sending url freeze app

Scheduled Pinned Locked Moved Unsolved Qt WebKit
4 Posts 2 Posters 1.4k Views
  • 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.
  • V Offline
    V Offline
    Vizi
    wrote on 25 Oct 2015, 15:45 last edited by Vizi
    #1

    Ok so,I try to do for a friend a bot applications that will automatically open a few links in the right order with the right settings. The problem is that when the law send a link 1 x times x second intervals entire application freeez. For small numbers of what i could check everything is done correctly and after the set time application hangs up. However, the need to remain logged and probably too long Freez will log
    The short code jst with the one button and this loop...

    #include "mainwindow.h"
    #include "ui_mainwindow.h" 
    #include <QThread>
    #include <QMessageBox>
    #include <QtNetwork>
    
    class Sleeper : public QThread
    {
    public:
        static void usleep(unsigned long usecs){QThread::usleep(usecs);}
        static void msleep(unsigned long msecs){QThread::msleep(msecs);}
        static void sleep(unsigned long secs){QThread::sleep(secs);}
    };
    
    void MainWindow::on_pushButton_6_clicked()
    {
        if(ui->checkBox->isChecked()){
            QMessageBox::information(this,"test",ui->spinBox->text()); //just for test, here comes another link
        }
        for( int i=0; i<ui->spinBox->value(); ++i )
        {
        ui->webView->load(QUrl("http://google.pl"));
        Sleeper::sleep(1);
        }
    }
    

    Is ther any way to not freez gui? I;m totaly newbie in qt and C++ programing so i can;t resove is by myself :S

    R 1 Reply Last reply 25 Oct 2015, 21:00
    0
    • V Vizi
      25 Oct 2015, 15:45

      Ok so,I try to do for a friend a bot applications that will automatically open a few links in the right order with the right settings. The problem is that when the law send a link 1 x times x second intervals entire application freeez. For small numbers of what i could check everything is done correctly and after the set time application hangs up. However, the need to remain logged and probably too long Freez will log
      The short code jst with the one button and this loop...

      #include "mainwindow.h"
      #include "ui_mainwindow.h" 
      #include <QThread>
      #include <QMessageBox>
      #include <QtNetwork>
      
      class Sleeper : public QThread
      {
      public:
          static void usleep(unsigned long usecs){QThread::usleep(usecs);}
          static void msleep(unsigned long msecs){QThread::msleep(msecs);}
          static void sleep(unsigned long secs){QThread::sleep(secs);}
      };
      
      void MainWindow::on_pushButton_6_clicked()
      {
          if(ui->checkBox->isChecked()){
              QMessageBox::information(this,"test",ui->spinBox->text()); //just for test, here comes another link
          }
          for( int i=0; i<ui->spinBox->value(); ++i )
          {
          ui->webView->load(QUrl("http://google.pl"));
          Sleeper::sleep(1);
          }
      }
      

      Is ther any way to not freez gui? I;m totaly newbie in qt and C++ programing so i can;t resove is by myself :S

      R Offline
      R Offline
      raf924
      wrote on 25 Oct 2015, 21:00 last edited by
      #2

      @Vizi Maybe using QTimer and signals/slots.

      1 Reply Last reply
      0
      • V Offline
        V Offline
        Vizi
        wrote on 26 Oct 2015, 18:59 last edited by
        #3

        the point is i i;m totaly newbie, I saw on a some guide gthat threads can run in background w/o lagging the application, it;s possible do this loop on thread?

        R 1 Reply Last reply 27 Oct 2015, 18:42
        0
        • V Vizi
          26 Oct 2015, 18:59

          the point is i i;m totaly newbie, I saw on a some guide gthat threads can run in background w/o lagging the application, it;s possible do this loop on thread?

          R Offline
          R Offline
          raf924
          wrote on 27 Oct 2015, 18:42 last edited by
          #4

          @Vizi See there: http://doc.qt.io/qt-5/qthread.html#details

          1 Reply Last reply
          0

          1/4

          25 Oct 2015, 15:45

          • Login

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