コード例 #1
0
ファイル: ncclientwindow.cpp プロジェクト: jhgao/ncclient
void NCClientWindow::on_pushButton_linkServer_2_clicked()
{

    if(m_isConnected2){
        emit sig_onConAbortCmd2();
    }else{
        //new connection

        if(ui->radioButton_protocol_TCP_2->isChecked()){
            i_con2 = new Connection(PROTOC_TCP);
        }else if(ui->radioButton_protocol_UDP_2->isChecked()){
            i_con2 = new Connection(PROTOC_UDP);
        }else{
            return;
        }

        connect(i_con2, SIGNAL(sig_progressPercent(uint)),
                this, SLOT(updateProgress2(uint)));
        connect(i_con2, SIGNAL(sig_gotBlockSN(quint32)),
                this, SLOT(onGotBlock2(quint32)));
        connect(i_con2, SIGNAL(connected()),
                this, SLOT(onConnected2()));
        connect(i_con2, SIGNAL(disconnected()),
                this, SLOT(onDisconnected2()));

        connect(this, SIGNAL(sig_onConAbortCmd2()),
                i_con2, SLOT(slot_abortWorks()));
        connect(this, SIGNAL(sig_onConConnectToHostCmd2(QString,quint16)),
                i_con2, SLOT(slot_connectToHost(QString,quint16)));

        //handle connection in another thread
        if( i_conThread2){
            i_conThread2->quit();
            i_conThread2->deleteLater();
        }
        i_conThread2 = new ExecThread(this);
        i_con2->moveToThread(i_conThread2);
        i_conThread2->start();

        emit sig_onConConnectToHostCmd2(
                    ui->lineEdit_serverAddr_2->text(),
                    (quint16)ui->lineEdit_serverPort_2->text().toInt());
    }
}
コード例 #2
0
CustomCircularProgressBar::CustomCircularProgressBar() : QWidget()//, m_val1(0), m_val2(0), m_val3(0)
{
  m_layout = new QHBoxLayout;

  m_progress_1 = new QCircularProgressBar;
  m_progress_1->setFixedSize(150, 150);

  m_progress_2 = new QCircularProgressBar;
  m_progress_2->setFixedSize(100, 100);

  m_progress_3 = new QCircularProgressBar;
  m_progress_3->setBacgroundProgressColor(Qt::red);
  m_progress_3->setProgressColor(Qt::green);
  m_progress_3->setForegroundColor(Qt::blue);
  m_progress_3->setTextColor(Qt::magenta);
  m_progress_3->setBorderColor(Qt::darkBlue);

  m_layout->addWidget(m_progress_1,0,Qt::AlignTop);
  m_layout->addWidget(m_progress_2,0,Qt::AlignTop);
  m_layout->addWidget(m_progress_3);

  this->setStyleSheet("QWidget {background-color: white;}");
  setLayout(m_layout);

  m_timer_1 = new QTimer;
  m_timer_2 = new QTimer;
  m_timer_3 = new QTimer;

  QObject::connect(m_timer_1, SIGNAL(timeout()), this, SLOT(updateProgress1()));
  QObject::connect(m_timer_2, SIGNAL(timeout()), this, SLOT(updateProgress2()));
  QObject::connect(m_timer_3, SIGNAL(timeout()), this, SLOT(updateProgress3()));

  m_timer_1->start(100);
  m_timer_2->start(100);
  m_timer_3->start(100);

}