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. Qtimer and Qprogressbar Connection
Forum Updated to NodeBB v4.3 + New Features

Qtimer and Qprogressbar Connection

Scheduled Pinned Locked Moved Unsolved General and Desktop
6 Posts 2 Posters 2.0k 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.
  • sankarapandiyanS Offline
    sankarapandiyanS Offline
    sankarapandiyan
    wrote on last edited by
    #1

    i have try to get a output as a progress bar runs and endsup with 10Seconds ,Here i am using timer but i dint know how to connect , its started and ends with its own timing , i want to get a output as a progress bar load with 10 seconds only and after that i want to close it . i have attached my code , Give some suggestion for this , Thanks in advance

    Timer::Timer(QWidget *parent)
    : QWidget(parent)
    {
    QHBoxLayout *layout = new QHBoxLayout();
    popup_progress = new QProgressBar();
    popup_progress->setMinimum(0);
    popup_progress->setMaximum(50);

    layout->addWidget(popup_progress);
    setLayout(layout);
    popupPB = new QTimer(this);
    connect(popupPB, &QTimer::timeout, this, &Timer::SetValueProgress);
    popupPB->start(10000);
    setWindowTitle(tr("popup"));
    resize(300, 0);
    

    }

    void Timer::SetValueProgress()
    {
    popup_progress->setValue(popup_progress->value()+1);
    int value = popup_progress->value();
    popup_progress->setValue(value);

    }

    JonBJ 1 Reply Last reply
    0
    • sankarapandiyanS sankarapandiyan

      i have try to get a output as a progress bar runs and endsup with 10Seconds ,Here i am using timer but i dint know how to connect , its started and ends with its own timing , i want to get a output as a progress bar load with 10 seconds only and after that i want to close it . i have attached my code , Give some suggestion for this , Thanks in advance

      Timer::Timer(QWidget *parent)
      : QWidget(parent)
      {
      QHBoxLayout *layout = new QHBoxLayout();
      popup_progress = new QProgressBar();
      popup_progress->setMinimum(0);
      popup_progress->setMaximum(50);

      layout->addWidget(popup_progress);
      setLayout(layout);
      popupPB = new QTimer(this);
      connect(popupPB, &QTimer::timeout, this, &Timer::SetValueProgress);
      popupPB->start(10000);
      setWindowTitle(tr("popup"));
      resize(300, 0);
      

      }

      void Timer::SetValueProgress()
      {
      popup_progress->setValue(popup_progress->value()+1);
      int value = popup_progress->value();
      popup_progress->setValue(value);

      }

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @sankarapandiyan
      Difficult to know what you mean. You want a progress bar which appears for 10 seconds and then disappears? During that 10 seconds, how do you want it to be updated? Do you mean, say, once per second for the 10 seconds, with each second being 10%?

      The code you show has a progress bar moving from 0 to 50 in ticks of 1 every 10 seconds. So I make it 500 seconds till it reaches 100%.

      sankarapandiyanS 2 Replies Last reply
      3
      • JonBJ JonB

        @sankarapandiyan
        Difficult to know what you mean. You want a progress bar which appears for 10 seconds and then disappears? During that 10 seconds, how do you want it to be updated? Do you mean, say, once per second for the 10 seconds, with each second being 10%?

        The code you show has a progress bar moving from 0 to 50 in ticks of 1 every 10 seconds. So I make it 500 seconds till it reaches 100%.

        sankarapandiyanS Offline
        sankarapandiyanS Offline
        sankarapandiyan
        wrote on last edited by
        #3

        @JonB Yes you are right , Then how to get like this .

        1 Reply Last reply
        0
        • JonBJ JonB

          @sankarapandiyan
          Difficult to know what you mean. You want a progress bar which appears for 10 seconds and then disappears? During that 10 seconds, how do you want it to be updated? Do you mean, say, once per second for the 10 seconds, with each second being 10%?

          The code you show has a progress bar moving from 0 to 50 in ticks of 1 every 10 seconds. So I make it 500 seconds till it reaches 100%.

          sankarapandiyanS Offline
          sankarapandiyanS Offline
          sankarapandiyan
          wrote on last edited by
          #4

          @JonB said in Qtimer and Qprogressbar Connection:

          Do you mean, say, once per second for the 10 seconds, with each second being 10%?

          this one i want to do

          JonBJ 1 Reply Last reply
          0
          • sankarapandiyanS sankarapandiyan

            @JonB said in Qtimer and Qprogressbar Connection:

            Do you mean, say, once per second for the 10 seconds, with each second being 10%?

            this one i want to do

            JonBJ Offline
            JonBJ Offline
            JonB
            wrote on last edited by JonB
            #5

            @sankarapandiyan
            Ok, so you want:

            • popupPB->start(1000); That's 1,000 ms == 1 second. So now your timer ticks once per second.

            • popup_progress->setMaximum(10); You only need 10 ticks to fill your progress bar, + 1 at a time.

            • Either count the ticks till they reach 10, or look at the popup_progress->value(). Once it has reached 10 (or on the next tick, as you please), disconnect the timer and get rid of it and the progress bar.

            1 Reply Last reply
            6
            • sankarapandiyanS Offline
              sankarapandiyanS Offline
              sankarapandiyan
              wrote on last edited by
              #6

              @JonB said in Qtimer and Qprogressbar Connection:

              popup_progress->setMaximum(10);

              Yes this is i want thanks @JonB

              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