Results 1 to 6 of 6

Thread: QProcess+QProgressBar

  1. #1
    Join Date
    Jun 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QProcess+QProgressBar

    Hello.

    Please help me with QProgressbar.
    Running script bash QProcess and output performance QProgressbar.

    Qt Code:
    1. #include "widget.h"
    2. #include "ui_widget.h"
    3. #include <QProcess>
    4. #include <QProgressBar>
    5.  
    6. Widget::Widget(QWidget *parent) :
    7. QWidget(parent),
    8. ui(new Ui::Widget)
    9. {
    10. ui->setupUi(this);
    11. }
    12.  
    13. Widget::~Widget()
    14. {
    15. delete ui;
    16. }
    17.  
    18. void Widget::on_pushButton_2_clicked()
    19. {
    20. QProcess process(this);
    21. process.startDetached("/bin/bash /opt/tall/ttings.sh");
    22. }
    23.  
    24. void Widget::on_progressBar_valueChanged(int value)
    25. {
    26.  
    27. }
    To copy to clipboard, switch view to plain text mode 
    I'm quite newbie to qt.
    If possible. Sample code.

  2. #2
    Join Date
    Oct 2009
    Posts
    483
    Thanked 97 Times in 94 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProcess+QProgressBar

    What do you mean by "output performance QProgressbar"? I understand that you want to run a bash command and display a progress bar, but you have not explained the expected connection between those two things.

  3. #3
    Join Date
    Jun 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProcess+QProgressBar

    Quote Originally Posted by yeye_olive View Post
    What do you mean by "output performance QProgressbar"? I understand that you want to run a bash command and display a progress bar, but you have not explained the expected connection between those two things.
    QProgressbar progress of the script bash.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: QProcess+QProgressBar

    How does the shell script report its progress?

  5. #5
    Join Date
    Jun 2015
    Posts
    3
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QProcess+QProgressBar

    Quote Originally Posted by ChrisW67 View Post
    How does the shell script report its progress?
    Script long.
    The code has a label:
    echo "progress=1"
    echo "progress=3"
    echo "progress=6"...
    Can they be transferred to the QProgressBar?

    Sorry. Originally from Azerbaijan. My English is poor.
    Do not be angry

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QProcess+QProgressBar

    First you need to start the process in a way that QProcess stays connected to the script, i.e. not using startDetached (which as the name suggests detaches from the process after start).

    Then you need to react to the QProcess signals that indicate that the script has written output.
    Then you parse that output.
    Then you change the progressbar accordingly.

    Cheers,
    _

Similar Threads

  1. Replies: 1
    Last Post: 3rd June 2013, 13:11
  2. Replies: 0
    Last Post: 23rd March 2013, 19:23
  3. Qprocess and QProgressBar !!
    By jesse_mark in forum Qt Programming
    Replies: 1
    Last Post: 26th July 2012, 23:56
  4. QProgressBar with QProcess
    By Alir3z4 in forum Qt Programming
    Replies: 0
    Last Post: 11th November 2011, 08:44
  5. Replies: 0
    Last Post: 26th August 2010, 10:44

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.