Qt Code:
  1. MainWindow::MainWindow(QWidget *parent) :
  2. QMainWindow(parent),
  3. ui(new Ui::MainWindow)
  4. {
  5. ui->setupUi(this);
  6. #ifdef TRACE
  7. std::cout <<"TRACE START MainWindow Constructor File "<< __FILE__ << " Function " <<__FUNCTION__<<" @line "<< __LINE__<< std::endl;
  8. #endif
  9. BT_FormDeviceInquiry *deviceIquiry = new BT_FormDeviceInquiry();
  10. if(connect(deviceIquiry,SIGNAL(sendStatus(QString)),this,SLOT(displayStatusMessage(QString))))
  11. std::cout <<"SUCCESS SIGNALS / SLOTS CONNECTED "<< std::endl;
  12. else
  13. {
  14. std::cout <<"******************************************************FAILED CONNECTION " <<std::endl;
  15. exit(-1);
  16. }
  17. #ifdef TRACE
  18. std::cout <<"TRACE END MainWindow Constructor File "<< __FILE__ << " Function " <<__FUNCTION__<<" @line "<< __LINE__<< std::endl;
  19. #endif
  20. }
To copy to clipboard, switch view to plain text mode 



Does not get called
Qt Code:
  1. void MainWindow::displayStatusMessage( const QString & message )
  2. {
  3. #ifdef TRACE
  4. std::cout <<"TRACE \nFile "<< __FILE__ << "\nFunction " <<__FUNCTION__<<" \n@line "<< __LINE__<< std::endl;
  5. #endif
  6. /*
  7.   QStatusBar * pStatusBar = statusBar();
  8.   pStatusBar->showMessage( message, 5000 ); // A 5 second timeout
  9.   */
  10.  
  11. ui->statusbar->showMessage(message,5000);
  12. }
To copy to clipboard, switch view to plain text mode 

slot declaration in MainWIndow
Qt Code:
  1. int WriteStatus(const QString *message);
  2. // int WriteStatus(char *message);
  3.  
  4. public slots:
  5. void displayStatusMessage( const QString & message );
To copy to clipboard, switch view to plain text mode 




emit signal - using TRACE to verify execution
Qt Code:
  1. void BT_FormDeviceInquiry::scanFinished()
  2. {
  3. #ifdef TRACE
  4. std::cout <<"TRACE \nFunction "<< __FUNCTION__ << "\nFile " << __FILE__<< "\n@Line # "<< __LINE__<< std::endl;
  5. #endif
  6.  
  7. #ifdef BYPASS
  8. CurrentTime();
  9. QString text = "STATE start scan for near-by BT devices finished ";
  10. StatusBar(&text);
  11. #endif
  12.  
  13. ui->scan->setEnabled(true); // TODO does not re_enable button
  14.  
  15. // test signal
  16. #ifdef TRACE
  17. std::cout <<"TRACE START emit sendStatus \nFunction "<< __FUNCTION__ << "\nFile " << __FILE__<< "\n@Line # "<< __LINE__<< std::endl;
  18. #endif
  19.  
  20. emit sendStatus( "Status from SomeMethod" );
  21.  
  22. #ifdef TRACE
  23. std::cout <<"TRACE END emit sendStatus \nFunction "<< __FUNCTION__ << "\nFile " << __FILE__<< "\n@Line # "<< __LINE__<< std::endl;
  24. #endif
  25.  
  26. }
To copy to clipboard, switch view to plain text mode 

declaration of signal
Qt Code:
  1. public:
  2. // 82920202
  3. int TestFunction();
  4. // declare signal
  5. signals:
  6. void sendStatus( const QString & status );
  7.  
  8. // CCC chnaged to publick private:
  9. public:
  10. QBluetoothDeviceDiscoveryAgent *discoveryAgent;
  11. QBluetoothLocalDevice *localDevice;
  12. Ui_DeviceDiscovery *ui;
To copy to clipboard, switch view to plain text mode