Results 1 to 6 of 6

Thread: emit Signals

  1. #1
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default emit Signals

    what does not work ???

    Qt Code:
    1. class CWorkThread : public QThread
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CWorkThread(QObject *parent);
    7. ~CWorkThread();
    8. void run();
    9.  
    10. public slots:
    11. void FinishProc();
    12.  
    13. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. void CWorkThread::run()
    2. {
    3. CWorkFiles *files = new CWorkFiles;
    4. connect(files,SIGNAL(finished()),this,SLOT(FinishProc()));
    5. QApplication::beep();
    6. exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    this block newer running !
    Qt Code:
    1. void CWorkThread::FinishProc()
    2. {
    3. QApplication::beep();
    4. }
    To copy to clipboard, switch view to plain text mode 

    --------------------------

    Qt Code:
    1. class CWorkFiles : public QFile
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. CWorkFiles(QObject *parent = 0);
    7. ~CWorkFiles();
    8.  
    9. qint16 CopyFile(QString cSrc, QString cDst);
    10. qint16 MoveFile(QString cSrc, QString cDst);
    11. qint16 DeleteFile(QString cPath);
    12. qint16 IsFileExists(QString cPath);
    13.  
    14. signals:
    15. void finished();
    16.  
    17. };
    To copy to clipboard, switch view to plain text mode 

    Qt Code:
    1. qint16 CWorkFiles::CopyFile(QString cSrc, QString cDst)
    2. {
    3. emit finished();
    4. return 1;
    5. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: emit Signals

    Does CopyFiles ever gets called?

  3. #3
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: emit Signals

    I don't see CWorkFiles::CopyFile() getting called anywhere.

    PS. You should allocate that CWorkFiles object on stack (without new).
    J-P Nurmi

  4. #4
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: emit Signals

    yes, called !

    Qt Code:
    1. CWorkFiles::CWorkFiles(QObject *parent)
    2. : QFile(parent)
    3. {
    4. CopyFile("d:\\6.2-RELEASE-i386-docs.iso","d:\\tmn.iso");
    5. }
    To copy to clipboard, switch view to plain text mode 

    and rewrite:

    Qt Code:
    1. void CWorkThread::run()
    2. {
    3. CWorkFiles files;
    4. connect(&files,SIGNAL(finished()),this,SLOT(FinishProc()));
    5. QApplication::beep();
    6. exec();
    7. }
    To copy to clipboard, switch view to plain text mode 

    but no effect !

  5. #5
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: emit Signals

    It is because you make the connection after the function is getting called, in the constructor.

    Call it after you make the connection, outside the constructor, or make the connection inside the constructor.

    Regards

  6. #6
    Join Date
    Jul 2007
    Location
    BY.Minsk
    Posts
    90
    Thanks
    10
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: emit Signals

    thx !!! it's work

Similar Threads

  1. Signal defined in "a.h" can not emit in "b.cpp"
    By Shawn in forum Qt Programming
    Replies: 9
    Last Post: 21st May 2007, 16:55
  2. Signals and Slots question
    By Thoosle in forum Qt Programming
    Replies: 5
    Last Post: 5th December 2006, 00:24
  3. From extends QTreeWidgetItem emit signal?
    By patrik08 in forum Qt Programming
    Replies: 4
    Last Post: 19th May 2006, 14:54
  4. How and when to repaint a widget ?
    By yellowmat in forum Newbie
    Replies: 7
    Last Post: 3rd April 2006, 16:36
  5. KDE Signals
    By chombium in forum KDE Forum
    Replies: 1
    Last Post: 25th January 2006, 18:45

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.