本文整理汇总了C++中QTimer::start方法的典型用法代码示例。如果您正苦于以下问题:C++ QTimer::start方法的具体用法?C++ QTimer::start怎么用?C++ QTimer::start使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QTimer
的用法示例。
在下文中一共展示了QTimer::start方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: start
bool PromiseTimer::start(unsigned dwMillisecond)
{
timer.setSingleShot(true);
timer.start(dwMillisecond);
return true;
}
示例2: QMainWindow
BitcoinGUI::BitcoinGUI(QWidget *parent):
QMainWindow(parent),
clientModel(0),
walletModel(0),
encryptWalletAction(0),
changePassphraseAction(0),
unlockWalletAction(0),
lockWalletAction(0),
aboutQtAction(0),
trayIcon(0),
notificator(0),
rpcConsole(0),
nWeight(0)
{
setFixedSize(970, 550);
QFontDatabase::addApplicationFont(":/fonts/Bebas");
setWindowTitle(tr("Pentacoin") + " - " + tr("Wallet"));
qApp->setStyleSheet("QMainWindow { background-image:url(:images/bkg);border:none; } #frame { } QToolBar QLabel { padding-top: 0px;padding-bottom: 0px;spacing: 10px;} QToolBar QLabel:item { padding-top: 0px;padding-bottom: 0px;spacing: 10px;} #spacer { background: transparent;border:none; } #toolbar2 { border:none;width:0px;hight:0px;padding-top:40px;padding-bottom:0px; background-color: transparent; } #labelMiningIcon { padding-left:5px;font-family:Century Gothic;width:100%;font-size:10px;text-align:center;color:black; } QMenu { background-color: qlineargradient(spread:pad, x1:0.511, y1:1, x2:0.482909, y2:0, stop:0 rgba(232,232,232), stop:1 rgba(232,232,232)); color: black; padding-bottom:10px; } QMenu::item { color: black; background: transparent; } QMenu::item:selected { background-color:qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,stop: 0 rgba(99,99,99,45), stop: 1 rgba(99,99,99,45)); } QMenuBar { background-color: white; color: white; } QMenuBar::item { font-size:12px;padding-bottom:3px;padding-top:3px;padding-left:15px;padding-right:15px;color: black; background-color: white; } QMenuBar::item:selected { background-color:qlineargradient(x1: 0, y1: 0, x2: 0.5, y2: 0.5,stop: 0 rgba(99,99,99,45), stop: 1 rgba(99,99,99,45)); }");
#ifndef Q_OS_MAC
qApp->setWindowIcon(QIcon(":icons/bitcoin"));
setWindowIcon(QIcon(":icons/bitcoin"));
#else
setUnifiedTitleAndToolBarOnMac(true);
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
// Accept D&D of URIs
setAcceptDrops(true);
// Create actions for the toolbar, menu bar and tray/dock icon
createActions();
// Create application menu bar
createMenuBar();
// Create the toolbars
createToolBars();
// Create the tray icon (or setup the dock icon)
createTrayIcon();
// Create tabs
overviewPage = new OverviewPage();
transactionsPage = new QWidget(this);
QVBoxLayout *vbox = new QVBoxLayout();
transactionView = new TransactionView(this);
vbox->addWidget(transactionView);
transactionsPage->setLayout(vbox);
addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);
sendCoinsPage = new SendCoinsDialog(this);
signVerifyMessageDialog = new SignVerifyMessageDialog(this);
masternodeManagerPage = new MasternodeManager(this);
centralWidget = new QStackedWidget(this);
centralWidget->addWidget(overviewPage);
centralWidget->addWidget(transactionsPage);
centralWidget->addWidget(addressBookPage);
centralWidget->addWidget(receiveCoinsPage);
centralWidget->addWidget(sendCoinsPage);
centralWidget->addWidget(masternodeManagerPage);
setCentralWidget(centralWidget);
// Create status bar
statusBar();
// Status bar notification icons
QFrame *frameBlocks = new QFrame();
frameBlocks->setContentsMargins(0,0,0,0);
frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3);
labelEncryptionIcon = new QLabel();
labelStakingIcon = new QLabel();
labelConnectionsIcon = new QLabel();
labelBlocksIcon = new QLabel();
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelEncryptionIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelStakingIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelConnectionsIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelBlocksIcon);
frameBlocksLayout->addStretch();
if (GetBoolArg("-staking", true))
{
QTimer *timerStakingIcon = new QTimer(labelStakingIcon);
connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(updateStakingIcon()));
timerStakingIcon->start(30 * 1000);
updateStakingIcon();
}
// Progress bar and label for blocks download
//.........这里部分代码省略.........
示例3: startTimer
void startTimer(int msec) { auRepTimer.start(msec, true); }
示例4: paint
void QgsComposerLabel::paint( QPainter* painter, const QStyleOptionGraphicsItem* itemStyle, QWidget* pWidget )
{
Q_UNUSED( itemStyle );
Q_UNUSED( pWidget );
if ( !painter )
{
return;
}
drawBackground( painter );
painter->save();
double penWidth = pen().widthF();
QRectF painterRect( penWidth + mMargin, penWidth + mMargin, mTextBoxWidth - 2 * penWidth - 2 * mMargin, mTextBoxHeight - 2 * penWidth - 2 * mMargin );
painter->translate( rect().width() / 2.0, rect().height() / 2.0 );
painter->rotate( mRotation );
painter->translate( -mTextBoxWidth / 2.0, -mTextBoxHeight / 2.0 );
if ( mHtmlState )
{
painter->scale( 1.0 / mHtmlUnitsToMM / 10.0, 1.0 / mHtmlUnitsToMM / 10.0 );
QWebPage* webPage = new QWebPage();
//Setup event loop and timeout for rendering html
QEventLoop loop;
QTimer timeoutTimer;
timeoutTimer.setSingleShot( true );
//This makes the background transparent. Found on http://blog.qt.digia.com/blog/2009/06/30/transparent-qwebview-or-qwebpage/
QPalette palette = webPage->palette();
palette.setBrush( QPalette::Base, Qt::transparent );
webPage->setPalette( palette );
//webPage->setAttribute(Qt::WA_OpaquePaintEvent, false); //this does not compile, why ?
webPage->setViewportSize( QSize( painterRect.width() * mHtmlUnitsToMM * 10.0, painterRect.height() * mHtmlUnitsToMM * 10.0 ) );
webPage->mainFrame()->setZoomFactor( 10.0 );
webPage->mainFrame()->setScrollBarPolicy( Qt::Horizontal, Qt::ScrollBarAlwaysOff );
webPage->mainFrame()->setScrollBarPolicy( Qt::Vertical, Qt::ScrollBarAlwaysOff );
// QGIS segfaults when rendering web page while in composer if html
// contains images. So if we are not printing the composition, then
// disable image loading
if ( mComposition->plotStyle() != QgsComposition::Print &&
mComposition->plotStyle() != QgsComposition::Postscript )
{
webPage->settings()->setAttribute( QWebSettings::AutoLoadImages, false );
}
//Connect timeout and webpage loadFinished signals to loop
connect( &timeoutTimer, SIGNAL( timeout() ), &loop, SLOT( quit() ) );
connect( webPage, SIGNAL( loadFinished( bool ) ), &loop, SLOT( quit() ) );
//mHtmlLoaded tracks whether the QWebPage has completed loading
//its html contents, set it initially to false. The loadingHtmlFinished slot will
//set this to true after html is loaded.
mHtmlLoaded = false;
connect( webPage, SIGNAL( loadFinished( bool ) ), SLOT( loadingHtmlFinished( bool ) ) );
webPage->mainFrame()->setHtml( displayText() );
//For very basic html labels with no external assets, the html load will already be
//complete before we even get a chance to start the QEventLoop. Make sure we check
//this before starting the loop
if ( !mHtmlLoaded )
{
// Start a 20 second timeout in case html loading will never complete
timeoutTimer.start( 20000 );
// Pause until html is loaded
loop.exec();
}
webPage->mainFrame()->render( painter );//DELETE WEBPAGE ?
}
else
{
示例5: TryCorrectGoogleVersions
void UrlFactory::TryCorrectGoogleVersions()
{
QMutexLocker locker(&mutex);
if(CorrectGoogleVersions && !IsCorrectGoogleVersions())
{
QNetworkReply *reply;
QNetworkRequest qheader;
QNetworkAccessManager network;
QEventLoop q;
QTimer tT;
tT.setSingleShot(true);
connect(&network, SIGNAL(finished(QNetworkReply*)),
&q, SLOT(quit()));
connect(&tT, SIGNAL(timeout()), &q, SLOT(quit()));
network.setProxy(Proxy);
#ifdef DEBUG_URLFACTORY
qDebug()<<"Correct GoogleVersion";
#endif //DEBUG_URLFACTORY
setIsCorrectGoogleVersions(true);
QString url = "http://maps.google.com";
qheader.setUrl(QUrl(url));
qheader.setRawHeader("User-Agent",UserAgent);
reply=network.get(qheader);
tT.start(Timeout);
q.exec();
if(!tT.isActive())
return;
tT.stop();
if( (reply->error()!=QNetworkReply::NoError))
{
#ifdef DEBUG_URLFACTORY
qDebug()<<"Try corrected version withou abort or error:"<<reply->errorString();
#endif //DEBUG_URLFACTORY
return;
}
QString html=QString(reply->readAll());
QRegExp reg("\"*http://mt0.google.com/vt/[email protected](\\d*)",Qt::CaseInsensitive);
if(reg.indexIn(html)!=-1)
{
QStringList gc=reg.capturedTexts();
VersionGoogleMap = QString("[email protected]%1").arg(gc[1]);
VersionGoogleMapChina = VersionGoogleMap;
#ifdef DEBUG_URLFACTORY
qDebug()<<"TryCorrectGoogleVersions, VersionGoogleMap: "<<VersionGoogleMap;
#endif //DEBUG_URLFACTORY
}
reg=QRegExp("\"*http://mt0.google.com/vt/[email protected](\\d*)",Qt::CaseInsensitive);
if(reg.indexIn(html)!=-1)
{
QStringList gc=reg.capturedTexts();
VersionGoogleLabels = QString("[email protected]%1").arg(gc[1]);
VersionGoogleLabelsChina = VersionGoogleLabels;
#ifdef DEBUG_URLFACTORY
qDebug()<<"TryCorrectGoogleVersions, VersionGoogleLabels: "<<VersionGoogleLabels;
#endif //DEBUG_URLFACTORY
}
reg=QRegExp("\"*http://khm0.google.com/kh/v=(\\d*)",Qt::CaseInsensitive);
if(reg.indexIn(html)!=-1)
{
QStringList gc=reg.capturedTexts();
VersionGoogleSatellite = gc[1];
VersionGoogleSatelliteKorea = VersionGoogleSatellite;
VersionGoogleSatelliteChina = "[email protected]" + VersionGoogleSatellite;
qDebug()<<"TryCorrectGoogleVersions, VersionGoogleSatellite: "<<VersionGoogleSatellite;
}
reg=QRegExp("\"*http://mt0.google.com/vt/[email protected](\\d*),[email protected](\\d*)",Qt::CaseInsensitive);
if(reg.indexIn(html)!=-1)
{
QStringList gc=reg.capturedTexts();
VersionGoogleTerrain = QString("[email protected]%1,[email protected]%2").arg(gc[1]).arg(gc[2]);
VersionGoogleTerrainChina = VersionGoogleTerrain;
#ifdef DEBUG_URLFACTORY
qDebug()<<"TryCorrectGoogleVersions, VersionGoogleTerrain: "<<VersionGoogleTerrain;
#endif //DEBUG_URLFACTORY
}
reply->deleteLater();
}
示例6: message
Scene::Scene( QUndoStack* undoStack ) : QGraphicsScene()
{
// create timer
for (double k=0; k<=359; k=k+1)
{
// These two lines throw a casting error.
//
//
//
//sine[k]=qSin(k*PI/180);
//cosine[k]=qCos(k*PI/180);
//
//
//
//
//
}
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(manageObjects()));
//connect(timer, SIGNAL(timeout()), this, SLOT(collisionDetection()));
timer->start(1000/25); // fire the timer 25 times per second
// initialise variables
m_undoStack = undoStack;
this->setSceneRect(0,0,WINDOW_WIDTH-20, WINDOW_HEIGHT-40);
// create invisible item to provide default top-left anchor to scene
addLine( 0, 0, 0, 1, QPen(Qt::transparent, 1) );
// connect selectionChanged signal to selectStations slot
connect( this, SIGNAL(selectionChanged()), this, SLOT(selectStations()) );
// set local variables and check if existing station clicked
qreal stationX = .5*WINDOW_WIDTH;
qreal stationY = .45*WINDOW_HEIGHT;
qreal asteroidX[4] = {0.75*WINDOW_WIDTH,0.65*WINDOW_WIDTH , 0.55*WINDOW_WIDTH, 0.45*WINDOW_WIDTH};
qreal asteroidY[4] = {0.75*WINDOW_WIDTH,0.65*WINDOW_WIDTH , 0.55*WINDOW_WIDTH, 0.45*WINDOW_WIDTH};
qreal bulletX = 0.25*WINDOW_WIDTH;
qreal bulletY = 0.25*WINDOW_HEIGHT;
qreal asteroidMoveX = -1;
qreal asteroidMoveY = -1;
qreal xDest, yDest;
Station* station = dynamic_cast<Station*>( itemAt( stationX, stationY ) );
m_undoStack->push( new CommandStationAdd( this, stationX, stationY ) );
emit message( QString("Ship add at %1,%2").arg(stationX).arg(stationY) );
for(int i=0; i<=4; i++){
Asteroid* asteroid = dynamic_cast<Asteroid*>( itemAt( asteroidX[i], asteroidY[i]) );
listOfAsteroids->append(asteroid);
m_undoStack->push( new CommandAsteroidAdd( this, asteroidX[i], asteroidY[i] ) );
emit message( QString("Asteroid add at %1,%2").arg(asteroidX[i]).arg(asteroidY[i]) );
}
Bullet* bullet = dynamic_cast<Bullet*>( itemAt( bulletX, bulletY ) );
m_undoStack->push( new CommandBulletAdd( this, bulletX, bulletY ) );
emit message( QString("Bullet add at %1,%2").arg(bulletX).arg(bulletY) );
/*
asteroid = dynamic_cast<Asteroid*>( itemAt( asteroidX, asteroidY ));
m_undoStack->push( new CommandAsteroidDelete( this, asteroid ) );
dynamic_cast<Asteroid*>(itemAt(50,300));
m_undoStack->push( new CommandAsteroidAdd( this, 50, 300 ) );
*/
}
示例7: QMainWindow
BitcoinGUI::BitcoinGUI(QWidget *parent):
QMainWindow(parent),
clientModel(0),
walletModel(0),
encryptWalletAction(0),
changePassphraseAction(0),
unlockWalletAction(0),
lockWalletAction(0),
aboutQtAction(0),
trayIcon(0),
notificator(0),
rpcConsole(0),
nWeight(0)
{
// resize(850, 550);
setFixedSize(920, 560);
setWindowTitle(tr("ParkByte") + " - " + tr("Wallet"));
#ifndef Q_OS_MAC
qApp->setWindowIcon(QIcon(":icons/bitcoin"));
setWindowIcon(QIcon(":icons/bitcoin"));
#else
setUnifiedTitleAndToolBarOnMac(true);
QApplication::setAttribute(Qt::AA_DontShowIconsInMenus);
#endif
// Accept D&D of URIs
setAcceptDrops(true);
// Create actions for the toolbar, menu bar and tray/dock icon
createActions();
// Create application menu bar
createMenuBar();
// Create the toolbars
createToolBars();
// Create the tray icon (or setup the dock icon)
createTrayIcon();
// Create tabs
overviewPage = new OverviewPage();
blockBrowser = new BlockBrowser(this); //block
transactionsPage = new QWidget(this);
QVBoxLayout *vbox = new QVBoxLayout();
transactionView = new TransactionView(this);
vbox->addWidget(transactionView);
transactionsPage->setLayout(vbox);
addressBookPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::SendingTab);
receiveCoinsPage = new AddressBookPage(AddressBookPage::ForEditing, AddressBookPage::ReceivingTab);
sendCoinsPage = new SendCoinsDialog(this);
signVerifyMessageDialog = new SignVerifyMessageDialog(this);
centralWidget = new QStackedWidget(this);
centralWidget->addWidget(overviewPage);
centralWidget->addWidget(blockBrowser); // block
centralWidget->addWidget(transactionsPage);
centralWidget->addWidget(addressBookPage);
centralWidget->addWidget(receiveCoinsPage);
centralWidget->addWidget(sendCoinsPage);
setCentralWidget(centralWidget);
// Create status bar
statusBar();
// Status bar notification icons
QFrame *frameBlocks = new QFrame();
frameBlocks->setContentsMargins(0,0,0,0);
frameBlocks->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
QHBoxLayout *frameBlocksLayout = new QHBoxLayout(frameBlocks);
frameBlocksLayout->setContentsMargins(3,0,3,0);
frameBlocksLayout->setSpacing(3);
labelEncryptionIcon = new QLabel();
labelStakingIcon = new QLabel();
labelConnectionsIcon = new QLabel();
labelBlocksIcon = new QLabel();
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelEncryptionIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelStakingIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelConnectionsIcon);
frameBlocksLayout->addStretch();
frameBlocksLayout->addWidget(labelBlocksIcon);
frameBlocksLayout->addStretch();
if (GetBoolArg("-staking", true))
{
QTimer *timerStakingIcon = new QTimer(labelStakingIcon);
connect(timerStakingIcon, SIGNAL(timeout()), this, SLOT(updateStakingIcon()));
timerStakingIcon->start(30 * 1000);
updateStakingIcon();
}
// Progress bar and label for blocks download
progressBarLabel = new QLabel();
//.........这里部分代码省略.........
示例8: makeStatus
void people::makeStatus(const QString text){
ui.label_status->setText(text);
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), ui.label_status, SLOT(clear()));
timer->start(10000);
}
示例9: main
int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);
QString serialPortName;
QString serialPortFriendlyName;
QString sisFile;
QString exeFile;
QStringList cmdLine;
QStringList args = QCoreApplication::arguments();
QTextStream outstream(stdout);
QTextStream errstream(stderr);
QString downloadRemoteFile;
QString downloadLocalFile;
int loglevel=1;
int timeout=0;
bool crashlog = true;
QString crashlogpath;
QListIterator<QString> it(args);
it.next(); //skip name of program
while (it.hasNext()) {
QString arg = it.next();
if (arg.startsWith("-")) {
if (arg == "--portname" || arg == "-p") {
CHECK_PARAMETER_EXISTS
serialPortName = it.next();
}
else if (arg == "--portfriendlyname" || arg == "-f") {
CHECK_PARAMETER_EXISTS
serialPortFriendlyName = it.next();
}
else if (arg == "--sis" || arg == "-s") {
CHECK_PARAMETER_EXISTS
sisFile = it.next();
if (!QFileInfo(sisFile).exists()) {
errstream << "Sis file (" << sisFile << ") doesn't exist" << endl;
return 1;
}
}
else if (arg == "--download" || arg == "-d") {
CHECK_PARAMETER_EXISTS
downloadRemoteFile = it.next();
CHECK_PARAMETER_EXISTS
downloadLocalFile = it.next();
}
else if (arg == "--timeout" || arg == "-t") {
CHECK_PARAMETER_EXISTS
bool ok;
timeout = it.next().toInt(&ok);
if (!ok) {
errstream << "Timeout must be specified in milliseconds" << endl;
return 1;
}
}
else if (arg == "--verbose" || arg == "-v")
loglevel=2;
else if (arg == "--quiet" || arg == "-q")
loglevel=0;
else if (arg == "--nocrashlog")
crashlog = false;
else if (arg == "--crashlogpath") {
CHECK_PARAMETER_EXISTS
crashlogpath = it.next();
}
else
errstream << "unknown command line option " << arg << endl;
} else {
exeFile = arg;
while(it.hasNext()) {
cmdLine.append(it.next());
}
}
}
if (exeFile.isEmpty() && sisFile.isEmpty() &&
(downloadLocalFile.isEmpty() || downloadRemoteFile.isEmpty())) {
printUsage(outstream, args[0]);
return 1;
}
if (serialPortName.isEmpty()) {
if (loglevel > 0)
outstream << "Detecting serial ports" << endl;
foreach (const SerialPortId &id, enumerateSerialPorts(loglevel)) {
if (loglevel > 0)
outstream << "Port Name: " << id.portName << ", "
<< "Friendly Name:" << id.friendlyName << endl;
if (!id.friendlyName.isEmpty()
&& serialPortFriendlyName.isEmpty()
&& (id.friendlyName.contains("symbian", Qt::CaseInsensitive)
|| id.friendlyName.contains("s60", Qt::CaseInsensitive)
|| id.friendlyName.contains("nokia", Qt::CaseInsensitive))) {
serialPortName = id.portName;
break;
} else if (!id.friendlyName.isEmpty()
&& !serialPortFriendlyName.isEmpty()
&& id.friendlyName.contains(serialPortFriendlyName)) {
serialPortName = id.portName;
break;
//.........这里部分代码省略.........
示例10: main
int main (int argc, char * argv[])
{
QApplication app( argc, argv );
// Create QGraphicsScene
QGraphicsScene scene;
scene.setSceneRect( -600, -250, 1200, 500 );
scene.setItemIndexMethod( QGraphicsScene::NoIndex );
// Draw road
scene.addLine( -350, -150, -350, -100 );
scene.addLine( -500, -100, -350, -100 );
scene.addLine( -500, -50, -350, -50 );
scene.addLine( -350, 150, -350, -50 );
scene.addLine( -300, 150, -300, -50 );
scene.addLine( -300, -150, -300, -100 );
scene.addLine( -300, -100, 300, -100 );
scene.addLine( -300, -50, 300, -50 );
scene.addLine( 350, -150, 350, -100 );
scene.addLine( 500, -100, 350, -100 );
scene.addLine( 500, -50, 350, -50 );
scene.addLine( 350, 150, 350, -50 );
scene.addLine( 300, 150, 300, -50 );
scene.addLine( 300, -150, 300, -100 );
scene.addLine( -325, -100, -325, -150 );
scene.addLine( -325, -50, -325, 150 );
scene.addLine( 325, -100, 325, -150 );
scene.addLine( 325, -50, 325, 150 );
scene.addLine( -475, -75, -350, -75 );
scene.addLine( -300, -75, 300, -75 );
scene.addLine( 475, -75, 350, -75 );
// Road notation
QGraphicsItem* ptext = scene.addText( "BSN" );
ptext->setPos( -340, -180 );
ptext = scene.addText( "BSS" );
ptext->setPos( -340, 150 );
ptext = scene.addText( "TBN" );
ptext->setPos( 310, -180 );
ptext = scene.addText( "TBS" );
ptext->setPos( 310, 150 );
ptext = scene.addText( "RHW" );
ptext->setPos( -550, -85 );
ptext = scene.addText( "RHE" );
ptext->setPos( 510, -85 );
// Draw traffic lights
// Add cars to scene
//Car *car = new Car;
CarGenerator *pcargen = new CarGenerator( eBSN, -337.5, -150, Qt::blue );
scene.addItem( pcargen );
//car->setStartPos();
// Create QGraphicsView
QGraphicsView view( &scene );
view.setViewportUpdateMode( QGraphicsView::BoundingRectViewportUpdate );
view.setWindowTitle( QT_TRANSLATE_NOOP(QGraphicsVIew, "Traffic simulation") );
view.show();
// Set Timer
QTimer timer;
QObject::connect( &timer, SIGNAL(timeout()), &scene, SLOT(advance()) );
timer.start( 1000/20 );
return app.exec();
}
示例11: main
int main(int argc, char* argv[])
{
try
{
terrama2::core::initializeTerraMA();
terrama2::core::registerFactories();
{
QCoreApplication app(argc, argv);
auto& serviceManager = terrama2::core::ServiceManager::getInstance();
std::map<std::string, std::string> connInfo { {"PG_HOST", TERRAMA2_DATABASE_HOST},
{"PG_PORT", TERRAMA2_DATABASE_PORT},
{"PG_USER", TERRAMA2_DATABASE_USERNAME},
{"PG_PASSWORD", TERRAMA2_DATABASE_PASSWORD},
{"PG_DB_NAME", TERRAMA2_DATABASE_DBNAME},
{"PG_CONNECT_TIMEOUT", "4"},
{"PG_CLIENT_ENCODING", "UTF-8"}
};
serviceManager.setLogConnectionInfo(connInfo);
serviceManager.setInstanceId(1);
auto dataManager = std::make_shared<terrama2::services::collector::core::DataManager>();
addInput(dataManager);
addOutput(dataManager);
addStaticDataSeries(dataManager);
terrama2::services::collector::core::Service service(dataManager);
service.start();
terrama2::services::collector::core::Collector* collector(new terrama2::services::collector::core::Collector());
terrama2::services::collector::core::CollectorPtr collectorPtr(collector);
collector->id = 1;
collector->projectId = 1;
collector->serviceInstanceId = 1;
collector->inputDataSeries = 1;
collector->outputDataSeries = 2;
collector->inputOutputMap.emplace(1, 2);
terrama2::services::collector::core::Intersection* intersection(new terrama2::services::collector::core::Intersection());
terrama2::services::collector::core::IntersectionPtr intersectionPtr(intersection);
// Adds the attribute "SIGLA" to the collected occurrences.
intersection->collectorId = collector->id;
std::vector<std::string> attrVec;
attrVec.push_back("sigla");
intersection->attributeMap[3] = attrVec;
collector->intersection = intersectionPtr;
dataManager->add(collectorPtr);
QTimer timer;
QObject::connect(&timer, SIGNAL(timeout()), QCoreApplication::instance(), SLOT(quit()));
timer.start(300000);
app.exec();
service.stopService();
}
terrama2::core::finalizeTerraMA();
}
catch(...)
{
// TODO: o que fazer com uncaught exception
std::cout << "\n\nException...\n" << std::endl;
}
return 0;
}
示例12: initializeGL
void initializeGL() {
gl::createVertexArrays(1, &vao);
gl::createBuffers(1, &positionBuffer);
gl::createBuffers(1, &colorBuffer);
gl::createBuffers(1, &indexBuffer);
vao.bindElementBuffer(indexBuffer);
constexpr static gl::Float colors[] = {
1,0,0,1,
0,1,0,1,
0,0,1,1,
1,1,0,1,
1,0,0,1,
0,1,0,1,
0,0,1,1,
1,1,0,1,
1,0,0,1,
0,1,0,1,
0,0,1,1,
1,1,0,1,
1,0,0,1,
0,1,0,1,
0,0,1,1,
1,1,0,1,
};
#define POS0 -0.5f, 0.5f,0,1,
#define POS1 -0.5f,-0.5f,0,1,
#define POS2 0.5f,-0.5f,0,1,
#define POS3 0.5f, 0.5f,0,1,
constexpr static gl::Float positions[] = {
POS0
POS1
POS2
POS3
POS1
POS2
POS3
POS0
POS2
POS3
POS0
POS1
POS3
POS0
POS1
POS2
};
gl::bufferData(positionBuffer, sizeof(positions), positions);
gl::bufferData(colorBuffer, sizeof(colors), colors);
constexpr static gl::UnsignedInteger index[] = { 0 };
gl::bufferData(indexBuffer, sizeof(index), index);
vao.bindBuffer(0, positionBuffer);
vao.bindBuffer(1, colorBuffer);
vao.bindDivisor(0, 1);
vao.bindDivisor(1, 1);
constexpr static char vs[] = R"(#version 450
layout(location=0) in vec4 iposition;
layout(location=1) in vec4 icolor;
out vec4 color;
void main(){
gl_Position = iposition;
gl_PointSize = 36+15*gl_InstanceID;
color = icolor;
}
)";
constexpr static char fs[] = R"(#version 450
in vec4 color;
out vec4 fcolor;
void main(){
fcolor = vec4( gl_PointCoord.xy ,color.x, 1);
}
)";
program = gl::VFProgramLoadSources(vs, fs);
{
typedef void(QTimer::*TT)();
timer.connect(&timer,TT(&QTimer::timeout),
[this]() {
++baseIndex;
if (baseIndex > 3) { baseIndex = 0; }
super->updateGL();
}
);
timer.start(666);
}
}
示例13: plot
Window::Window() : plot( QString("Velocity") ), gain(5), count(0) // <-- 'c++ initialisation list' - google it!
{
//taken purely from online, not our code!
//http://qwt.sourceforge.net/class_qwt_analog_clock.html
//
QwtAnalogClock *clock = new QwtAnalogClock();
clock->scaleDraw()->setPenWidth(3);
clock->setLineWidth(6);
clock->setFrameShadow(QwtDial::Sunken);
clock->setTime();
// update the clock every second
QTimer *timer = new QTimer(clock);
timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime()));
timer->start(1000);
// set up the gain knob
knob.setValue(gain);
// use the Qt signals/slots framework to update the gain -
// every time the knob is moved, the setGain function will be called
connect( &knob, SIGNAL(valueChanged(double)), SLOT(setGain(double)) );
// set up the thermometer
thermo.setFillBrush( QBrush(Qt::red) );
thermo.setRange(0, 20);
//thermo.show();
// set up the initial plot data
for( int index=0; index<plotDataSize; ++index )
{
xData[index] = index;
yData[index] = gain * sin( M_PI * index/50 );
}
// make a plot curve from the data and attach it to the plot
curve.setSamples(xData, yData, plotDataSize);
curve.attach(&plot);
plot.replot();
plot.show();
// set up the layout - knob above thermometer
//vLayout.addWidget(&knob);
vLayout.addWidget(clock);
//vLayout.addWidget(&thermo);
// plot to the left of knob and thermometer
hLayout.addLayout(&vLayout);
hLayout.addWidget(&plot);
setLayout(&hLayout);
std::cout << "It is working\n";
//Below is NOT THE RIGHT WAY TO DO IT, the preferred way is to use
// moveToThread() on QObject and then using the Signals and Slots sys-
//tem. Essentially use the connect function on the QObject instantia-
//tion to hook up the start() method of the QThread object and the
// desired method that does the processing
DaThread *ls =new DaThread();
uint64_t ls_time=1900;
int ls_boolean = 1;
uint64_t rs_time=1100;
int rs_boolean = 1;
ls-> initiate(xData, yData,&ls_time, &ls_boolean, &rs_time,&rs_boolean);
ls->start();
std::cout << "It is working\n";
//start the servos around the time the data starts to be read
// ServoThread *leftServo =new ServoThread();
// leftServo-> initiate(PIN, &ls_time, &ls_boolean);
// leftServo->start();
std::cout << "It is working1\n";
// ServoThread *rightServo =new ServoThread();
// rightServo-> initiate(PIN2, &rs_time, &rs_boolean);
// rightServo->start();
// ls_boolean =0;
// rs_boolean =0;
}
示例14: setupGui
void RegularBattleScene::setupGui()
{
int nslots = data()->numberOfSlots();
gui.nick.resize(nslots);
gui.level.resize(nslots);
gui.gender.resize(nslots);
gui.bars.resize(nslots);
gui.status.resize(nslots);
QVBoxLayout *l= new QVBoxLayout(this);
l->setMargin(0);
/* As anyway the GraphicsZone is a fixed size, it's useless to
resize that part, might as well let the chat be resized */
l->setSizeConstraint(QLayout::SetFixedSize);
QHBoxLayout *firstLine = new QHBoxLayout();
l->addLayout(firstLine);
QHBoxLayout *midzone = new QHBoxLayout();
l->addLayout(midzone);
QHBoxLayout *lastLine = new QHBoxLayout();
l->addLayout(lastLine);
QVBoxLayout *teamAndName[2];
for (int i = 0; i < 2; i++) {
teamAndName[i] = new QVBoxLayout();
teamAndName[i]->addLayout(createTeamLayout(gui.pokeballs[i]));
teamAndName[i]->addWidget(gui.trainers[i] = new QLabel(data()->name(i)),0, Qt::AlignRight);
gui.trainers[i]->setObjectName("TrainerNick");
}
firstLine->addWidget(createFullBarLayout(nslots, opponent()));
firstLine->addLayout(teamAndName[opponent()]);
gui.zone = new GraphicsZone(data(), gui.theme);
/* Make the code below more generic? */
QVBoxLayout *midme = new QVBoxLayout();
midzone->addLayout(midme);
midme->addStretch(100);
gui.timers[myself()] = new QProgressBar();
gui.timers[myself()]->setObjectName("TimeOut"); //for style sheets
gui.timers[myself()]->setRange(0,300);
QLabel *mybox = new QLabel();
mybox->setObjectName("MyTrainerBox");
mybox->setFixedSize(82,82);
mybox->setPixmap(gui.theme->trainerSprite(data()->avatar(myself())));
midme->addWidget(gui.timers[myself()]);
midme->addWidget(mybox);
midzone->addWidget(gui.zone);
QVBoxLayout *midopp = new QVBoxLayout();
midzone->addLayout(midopp);
midopp->addStretch(100);
gui.timers[opponent()] = new QProgressBar();
gui.timers[opponent()]->setObjectName("TimeOut"); //for style sheets
gui.timers[opponent()]->setRange(0,300);
QLabel *oppbox = new QLabel();
oppbox->setPixmap(gui.theme->trainerSprite(data()->avatar(opponent())));
oppbox->setObjectName("OppTrainerBox");
oppbox->setFixedSize(82,82);
midopp->addWidget(oppbox);
midopp->addWidget(gui.timers[opponent()]);
lastLine->addLayout(teamAndName[myself()]);
lastLine->addWidget(createFullBarLayout(nslots, myself()));
QTimer *t = new QTimer (this);
t->start(200);
connect(t, SIGNAL(timeout()), SLOT(updateTimers()));
}
示例15: if
//.........这里部分代码省略.........
connect(_processing_button, SIGNAL(clicked()), this, SLOT(_processing_button_pressed()));
_skip_back_button = new QPushButton(_controlsParent);
_skip_back_button->setObjectName("_skip_back_button");
_skip_back_button->setFocusPolicy(Qt::NoFocus);
_skip_back_button->show();
connect(_skip_back_button, SIGNAL(clicked()), this, SLOT(_skip_back()));
_pause_button = new QPushButton(_controlsParent);
_pause_button->setObjectName("_pause_button");
_pause_button->setCheckable(true);
_pause_button->setFocusPolicy(Qt::NoFocus);
_pause_button->show();
connect(_pause_button, SIGNAL(clicked()), this, SLOT(_pause_button_pressed()));
_play_button = new QPushButton(_controlsParent);
_play_button->setObjectName("_play_button");
_play_button->setCheckable(true);
_play_button->setFocusPolicy(Qt::NoFocus);
_play_button->show();
connect(_play_button, SIGNAL(clicked()), this, SLOT(_play_button_pressed()));
_time_line = new QSSRTimeLine(_controlsParent, UPDATEINTERVALFORQTWIDGETS);
_time_line->show();
connect(_time_line, SIGNAL(signal_transport_locate(float)), this, SLOT(_transport_locate(float)));
_cpu_label = new QCPULabel(_controlsParent, UPDATEINTERVALFORQTWIDGETS);
_cpu_label->show();
_cpu_label_text_tag = new QLabel(_controlsParent);
_cpu_label_text_tag->setAlignment(Qt::AlignCenter);
_cpu_label_text_tag->setText("cpu");
_zoom_label = new QZoomLabel(_controlsParent);
_zoom_label->show();
connect(_zoom_label, SIGNAL(signal_zoom_changed(int)), this, SLOT(_set_zoom(int)));
connect(this, SIGNAL(signal_zoom_set(int)), _zoom_label, SLOT(update_display(int)));
_zoom_label_text_tag = new QLabel(_controlsParent);
_zoom_label_text_tag->setAlignment(Qt::AlignCenter);
_zoom_label_text_tag->setText("zoom");
_zoom_label_text_tag->show();
_volume_slider = new QVolumeSlider(_controlsParent);
_volume_slider->show();
connect(_volume_slider, SIGNAL(signal_volume_changed(float)), this, SLOT(_set_master_volume(float)));
_volume_slider_text_tag = new QLabel(_controlsParent);
_volume_slider_text_tag->setAlignment(Qt::AlignCenter);
_volume_slider_text_tag->setText("level");
_volume_slider_text_tag->show();
// open_file_label = new QClickTextLabel( this );
// open_file_label->setGeometry( QRect( XREF, YREF, 270, 39 ) );
// open_file_label->setSizePolicy( QSizePolicy( (QSizePolicy::SizeType)1, (QSizePolicy::SizeType)1, 0, 0, open_file_label->sizePolicy().hasHeightForWidth() ) );
// put labels into correct position
_file_menu_label->setGeometry(DEFAULTFRAMELEFT, 24, FILEMENUWIDTH, 24);
_processing_button->setGeometry(DEFAULTFRAMELEFT+FILEMENUWIDTH+
BETWEENBUTTONSPACE, 20,
BUTTONWIDTH, BUTTONHEIGHT);
_skip_back_button->setGeometry(DEFAULTFRAMELEFT+FILEMENUWIDTH+
BETWEENBUTTONSPACE+BUTTONWIDTH+
BETWEENBUTTONSPACE, 20,
BUTTONWIDTH, BUTTONHEIGHT);
_pause_button->setGeometry(DEFAULTFRAMELEFT+FILEMENUWIDTH+
2*(BETWEENBUTTONSPACE+BUTTONWIDTH)+
BETWEENBUTTONSPACE, 20,
BUTTONWIDTH, BUTTONHEIGHT);
_play_button->setGeometry(DEFAULTFRAMELEFT+FILEMENUWIDTH+
3*(BETWEENBUTTONSPACE+BUTTONWIDTH)+
BETWEENBUTTONSPACE, 20,
BUTTONWIDTH, BUTTONHEIGHT);
// functional inits
_deselect_all_sources(); // no source selected
#ifdef ENABLE_FLOATING_CONTROL_PANEL
// scene menu is not shown if floating control panel is used
VERBOSE("Floating control panel is used, scene menu will not be shown.");
(void)path_to_scene_menu;
#else
// create the scene menu if an according config file is present
_create_scene_menu(path_to_scene_menu);
#endif
// update screen with update_frequency
QTimer *timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(_update_screen()));
timer->start(static_cast<unsigned int>(1.0f/static_cast<float>(update_frequency) * 1000.0f));
#ifdef ENABLE_FLOATING_CONTROL_PANEL
_resizeControls(_controlsParent->width());
#endif
}