コード例 #1
0
ファイル: myCallback.cpp プロジェクト: cherry-wb/quietheart
void MyCallback::clicked()
{
	//t = new MyThread(this);
	MyThread *twait = new MyThread(this);
	twait->setObjectName("WaitThread");
	twait->start();

	MyThread *tmodify = new MyThread(this);
	tmodify->setObjectName("ModifyThread");
	tmodify->start();
}
コード例 #2
0
ファイル: myserver.cpp プロジェクト: thomasalvatran/June2015
void MyServer::incomingConnection(int socketDescriptor)
{
    qDebug() << socketDescriptor << " Connecting...";
    MyThread *thread = new MyThread(socketDescriptor,this);
    connect(thread, SIGNAL(finished()),thread, SLOT(deleteLater()));
    thread->start();
}
コード例 #3
0
ファイル: MyObject.cpp プロジェクト: Amartel1986/test
void MyObject::start()
{
    QTimer *timer = new QTimer(this);
    timer->setInterval(1000);
    connect(timer, SIGNAL(timeout()), SLOT(DoSomething()));
    MyThread *t = new MyThread(this);
    connect(t, SIGNAL(finished()), SLOT(onFinished()));
    connect(t, SIGNAL(finished()), timer, SLOT(start()));
    t->start();
}
コード例 #4
0
ファイル: main.cpp プロジェクト: ggurbet/qtexamples
int main(int argc, char *argv[])
{
	QCoreApplication a(argc, argv);

	MyThread mThread;
	mThread.start();

	mThread.wait();
	qDebug() << "Done!";

	return a.exec();
}
コード例 #5
0
ファイル: 3sexwindow.cpp プロジェクト: halukasama/learnQt
SexWindow::SexWindow(QWidget *parent) 
    : QMainWindow(parent)
    , ui(new Ui_MainWindow)
{
    ui->setupUi(this);
    MyThread *mythread = new MyThread;
    
    /** 元类型的注册方法 **/
    int id = qRegisterMetaType<PEOPLE>("PEOPLE");
    
    connect(mythread, SIGNAL(changeText(PEOPLE)), this, 
            SLOT(labelSetText(PEOPLE)),Qt::QueuedConnection);  
    mythread->start();  
}
コード例 #6
0
ファイル: main.cpp プロジェクト: woaitubage/QT
int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    MyThread mThread;
    qDebug()<<"GUI thread before MyThread start()"
             <<a.thread()->currentThread();


    qDebug()<<"GUI thread after start()"
            <<a.thread()->currentThread();
    mThread.start();
    mThread.wait();

    qDebug()<<"GUI thread after wait()"
           <<a.thread()->currentThread();


    return a.exec();
}
コード例 #7
0
ファイル: buffer.cpp プロジェクト: SiteView/ecc82Server
extern "C" int main(int argc, char **argv)
{
	char buffer[32];
	const char *cp;
	MyThread *thr = new MyThread();
	thr->start();

	for(;;)
	{
		cin.getline(buffer, sizeof(buffer));
		if(!strnicmp(buffer, "bye", 3))
			break;
		cp = buffer;
		while(*cp)
			thr->post((void *)(cp++), 0);
		cout << "post complete!" << endl;
	}
	delete thr;
	return 0;
}
コード例 #8
0
void MyServer::incomingConnection(qintptr socketDescriptor)
{
    // We have a new connection
    qDebug() << socketDescriptor << " Connecting...";

    MyThread *thread = new MyThread(socketDescriptor, this);
    // connect signal/slot
    // once a thread is not needed, it will be beleted later
    connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
    connect(thread, SIGNAL(auth(QString , QString )), this, SLOT(authUsuario(QString , QString ))); //Slot autenticacion
    connect(this, SIGNAL(clienteDenegado()),thread, SLOT(expulsarCliente()));   //Slot expulsarCliente
    connect(thread, SIGNAL(registrar(QString , QString )), this, SLOT(regisUsuario(QString , QString ))); //Slot registrar

    connect(this, SIGNAL(notifaciones(QString)), thread, SLOT(llegadaNotificacion(QString))); //Comunicacion textual servidor-cliente
    connect(thread, SIGNAL(eliminarUsuario(QString)), this, SLOT(dropUser(QString))); //Slot registrar
    connect(thread,SIGNAL(cambiarPermisos(QString,QString,QString)),this,SLOT(actualizarPermisos(QString,QString,QString)));

    connect(thread,SIGNAL(removerPermisos(QString,QString,QString)),this,SLOT(quitarPermisos(QString,QString,QString)));
    //connect(thread,SIGNAL(sentenciaDeUsuario(QString)),this,SLOT(sentenciaNuevaUsuario(QString)));


    thread->start();
}
コード例 #9
0
ファイル: main.cpp プロジェクト: MakSim345/QT-Dev
int main (int argc, char ** argv)
{
    // QCoreApplication app (argc, argv);
    QApplication app (argc, argv);
    QWidget *mainWindow = new QWidget();
    QVBoxLayout *vlayout = new QVBoxLayout();	 
    // QHBoxLayout *hlayout = new QHBoxLayout;    
    QProgressBar *prb = new QProgressBar();
    ThreadSignal *thrd = new ThreadSignal();
    
    myWidget* newButton = new myWidget("Do Not press");
    std::cout << "In BasicDataChannel run" << std::endl;

    //printf ("START main application\n");    
    MyThread *mythread = new MyThread("24ClockEffect1.wav");    

    vlayout->addWidget(newButton);
    vlayout->addWidget(prb);
    mainWindow->setLayout(vlayout);
    mainWindow->show();

    newButton->getThreadPointer(mythread);
    newButton->setConnections();

    QObject::connect(newButton, SIGNAL(clicked()), &app, SLOT (quit()) );
    //QObject::connect(newButton, SIGNAL(clicked()), &app, SLOT (setName(int)) );
    //QObject::connect(thrd, SIGNAL(progress(int)), prb, SLOT(setValue(int)) );
    //QObject::connect(mythread, SIGNAL(thEvent(int)), newButton, SLOT (recSignal()));
    QObject::connect(mythread, SIGNAL(thEvent(int)), prb, SLOT (setValue(int) ));
    //QObject::connect(mythread, SIGNAL(thEvent(int)), &app, SLOT (quit() ));

    mythread->start();
    //thrd->start();

    return app.exec();
}
コード例 #10
0
ファイル: AddDatabase.cpp プロジェクト: nmcle/baduK
/*******************************************************************88
  Start the Process of Adding a new Database
  Start the timer, change cursor, 
  Find out if we can create the database using the selected name
  If we can create the database then we change to the Progress Page 
  Then start Database->setupDatabase process.
**********************************************************************/
void SetupPage::start()
{
  timeSeconds_ = 0;
  MyThread* myThread = new MyThread(this);
  myThread->start();
  
  qApp->setOverrideCursor(QCursor(Qt::WaitCursor));
  addDatabase_->timer_ = new Timer; // Start timer 
  bool recursive = false;
  if (recursiveDirCheckBox->checkState() == Qt::Checked) {
    recursive = true;
  }
  bool eraseDuplicates = false;
  if (acceptDuplicatesCheckBox->checkState() == Qt::Checked) {
    eraseDuplicates = true;
  }
  
  QString name = databaseNameLineEdit->text();
  QModelIndex index = treeView->currentIndex();
  QString path = dirModel->filePath(index);
  setupDatabaseError result = 
      addDatabase_->mainWindow_->dbManager_->addDatabase(name.toStdString(),
      path.toStdString(), recursive);

  switch (result) {
    case NAME_TAKEN : {
      qApp->restoreOverrideCursor();
      myThread->quit();
      QMessageBox::information(this, "baduK", "Unable to create database with given name.\n" "Choose a different Database name.");
      return;
    }
    case DIR_TAKEN : {
      qApp->restoreOverrideCursor();
      myThread->quit();
      QMessageBox::information(this, "baduK", "Unable to create database directory.\n"
          "Choose a different Database name.");      
      return;
    }
    case ACCEPT : {
      break;
    }
    case NO_SGF : {
      qApp->restoreOverrideCursor();
      myThread->quit();
      QMessageBox::information(this, "messageDlg", "Specified Directory has no SGF files.\n"
          "Choose a different Directory.");
      QString name = databaseNameLineEdit->text();
      std::string strName = name.toStdString();
      addDatabase_->mainWindow_->dbManager_->deleteDatabase(strName);
      return;
    }
    case BAD_DIRECTORY : {
      qApp->restoreOverrideCursor();
      myThread->quit();
      QMessageBox::information(this, "baduK", "Specified Directory does not exist.\n"
          "Choose a different Directory.");
      
      if (ACCEPT != result) {
        QString name = databaseNameLineEdit->text();
        std::string strName = name.toStdString();
        addDatabase_->mainWindow_->dbManager_->deleteDatabase(strName);
      }
      return;
    }
    case UNABLE_TO_CREATE_DIR : {}
    case BAD_SGF : {}
    case CANCEL : {}
  }
  addDatabase_->stackedWidget->setCurrentWidget(addDatabase_->progressPage);
  addDatabase_->progressPage->labelCurrentTimeData->setText("0:00 Seconds");
  addDatabase_->repaint();
  addDatabase_->update();
  
  result = addDatabase_->mainWindow_->dbManager_->setupDatabase(
      addDatabase_->mainWindow_, eraseDuplicates);
  qApp->restoreOverrideCursor();
  myThread->quit();

  switch (result) {
    case NAME_TAKEN : {}
    case DIR_TAKEN : {}
    case BAD_DIRECTORY : {}
    case NO_SGF : {}
    case UNABLE_TO_CREATE_DIR : {}
    case BAD_SGF : {}
    case ACCEPT : {
      addDatabase_->progressPage->finishButton->setEnabled(true);
      break;
    }
    case CANCEL : {
      if (true == addDatabase_->progressPage->isBackClicked_) {
        addDatabase_->progressPage->back();
      }
      else {
        addDatabase_->progressPage->cancel();
      }
      break;
    }
  }
}
コード例 #11
0
ファイル: main.cpp プロジェクト: bjtj/oslayer
static void thread() {
	MyThread mt;
	mt.start();
	idle(100);
}
コード例 #12
0
ファイル: RButtonGrid.cpp プロジェクト: dgu123/dc-lib
int main( int argc, char **argv )
{
	int i, j;
	
	dc_init ();
	
	//allocates main page...
	mainPage=dc_malloc (sizeof (ProtectedData));
	
	//allocates one protected page per button...
	for (i=0; i<NumButtX; i++)
		for (j=0; j<NumButtY; j++)
			page[i][j]=dc_malloc (sizeof (ProtectedData));
	
	//QApplication a( argc, argv );
    MyApplication a( argc, argv );

	w=new MyWidget ();

	w->setGeometry (0, 0, MaxXSize, MaxYSize);
	w->show();

    MyThread *resizeThread = new MyThread ();
    resizeThread->start();

	int ret_value=a.exec();

    delete resizeThread;

	//frees main page...
	dc_free (mainPage);
	
	//frees protected pages...
	for (i=0; i<NumButtX; i++)
		for (j=0; j<NumButtY; j++)
			dc_free (page[i][j]);
	
	//for (i=0; i<LOG_ENTRIES; i++)
		//printf ("%f - %f\n", log_array[i].main_win_resize, log_array[i].last_button_resize);

    // dump DC profiling info
    if (dc_profile_on()) 
        dc_dump_profile_diff(stdout, 
                             &log_array_prof[numIter-4], 
                             &log_array_prof[numIter-3]);
    else {

        //computes avg and max resize evt processing time...
        elapsed_time_t avg;
        avg.real=0;
        avg.user=0;
        avg.system=0;
        avg.child_user=0;
        avg.child_system=0;
        
        double max=log_array[1].real;
        for (i=1; i<numIter-2; i++)
        {
            avg.real=avg.real+log_array[i].real;
            avg.user=avg.user+log_array[i].user;
            avg.system=avg.system+log_array[i].system;
            avg.child_user=avg.child_user+log_array[i].child_user;
            avg.child_system=avg.child_system+log_array[i].child_system;
            
            if (log_array[i].real>max)
                max=log_array[i].real;
        }

        divide_elapsed_time_by(&avg, numIter-2);
        printf ("\nTotal times per resize event:\n");
        printf ("Avg real = %f\n", avg.real);
        printf ("Avg user = %f\n", avg.user);
        printf ("Avg system = %f\n", avg.system);
        printf ("Avg child_user = %f\n", avg.child_user);
        printf ("Avg child_system = %f\n", avg.child_system);
        printf ("Max real = %f\n", max);
        
        avg.real=0;
        avg.user=0;
        avg.system=0;
        avg.child_user=0;
        avg.child_system=0;
        max=inter_array[1].real;
        for (i=1; i<numIter-2; i++)
        {
            avg.real=avg.real+inter_array[i].real;
            avg.user=avg.user+inter_array[i].user;
            avg.system=avg.system+inter_array[i].system;
            avg.child_user=avg.child_user+inter_array[i].child_user;
            avg.child_system=avg.child_system+inter_array[i].child_system;
            
            if (inter_array[i].real>max)
                max=inter_array[i].real;
        }
        
        divide_elapsed_time_by(&avg, numIter-2);
        printf ("\nChange propagation times only:\n");
        printf ("Avg real = %f\n", avg.real);
        printf ("Avg user = %f\n", avg.user);
        printf ("Avg system = %f\n", avg.system);
        printf ("Avg child_user = %f\n", avg.child_user);
        printf ("Avg child_system = %f\n", avg.child_system);
        printf ("Max real = %f\n", max);
    }

	return ret_value;
}