Results 1 to 2 of 2

Thread: How to emit progressTextChanged (QString) signal in QFutureWatcher?

  1. #1
    Join Date
    Feb 2012
    Posts
    1
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default How to emit progressTextChanged (QString) signal in QFutureWatcher?

    Having this code is possible to emit the progressTextChanged(QString) signal? i have tried but i when trying to access the signal the compiler says it is protected.

    Qt Code:
    1. //...
    2. //...
    3. QFuture<bool> future = QtConcurrent::run(
    4. this,
    5. &MyClass::runTheTask );
    6.  
    7. QFutureWatcher<bool> watcher;
    8. connect( &watcher, SIGNAL( progressTextChanged( const QString ) ),
    9. this, SLOT( appendMessageToStatusLineEdit( const QString ) ) );
    10. watcher.setFuture( future );
    11. future.waitForFinished();
    12.  
    13. // ...
    14. // ...
    To copy to clipboard, switch view to plain text mode 



    Qt Code:
    1. bool MyClass::runTheTask()
    2. {
    3. // do the task
    4.  
    5.  
    6.  
    7. // how to emit progress text signal???
    8. }
    9.  
    10. void MyClass::appendMessageToStatusLineEdit( const QString msg )
    11. {
    12. QMetaObject::invokeMethod( this,
    13. "doAppendMessageToStatusLineEdit",
    14. Qt::QueuedConnection,
    15. Q_ARG( QString, msg ) );
    16. }
    17.  
    18. void MyClass::doAppendMessageToStatusLineEdit( const QString msg )
    19. {
    20. _ui->statusTextEdit->append( msg );
    21. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: How to emit progressTextChanged (QString) signal in QFutureWatcher?

    you cant emit a signal that does not belong to your class.

    QFutureWatcher decides when to emit that signal - you do not!
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

Similar Threads

  1. QFutureWatcher finished() signal not working
    By DiamonDogX in forum Qt Programming
    Replies: 13
    Last Post: 25th October 2011, 19:27
  2. Replies: 2
    Last Post: 3rd May 2011, 21:22
  3. How to use progressTextChanged() signal in QFutureWatcher
    By DiamonDogX in forum Qt Programming
    Replies: 1
    Last Post: 9th June 2009, 16:41
  4. signal doesnt emit
    By mark2804 in forum Newbie
    Replies: 2
    Last Post: 25th December 2008, 23:36
  5. emit a signal
    By Morea in forum Qt Programming
    Replies: 2
    Last Post: 27th February 2006, 12:14

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.