本文整理汇总了C++中QProgressBar::setRange方法的典型用法代码示例。如果您正苦于以下问题:C++ QProgressBar::setRange方法的具体用法?C++ QProgressBar::setRange怎么用?C++ QProgressBar::setRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QProgressBar
的用法示例。
在下文中一共展示了QProgressBar::setRange方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SLOT
void
MessageBar::show( const QString& message, const QString& id )
{
QLabel* label = findChild<QLabel*>( id );
if (label && id.size()) {
if (message.isEmpty())
{
QProgressBar* p = label->findChild<QProgressBar*>();
if (p)
p->setRange( 0, 1 ),
p->setValue( 1 );
QTimer::singleShot( 3000, label, SLOT(deleteLater()) );
}
else
label->setText( message );
return;
}
label = new QLabel( message, ui.papyrus );
label->setBackgroundRole( QPalette::Base );
label->setMargin( 8 );
label->setIndent( 4 );
label->setTextFormat( Qt::RichText );
label->setOpenExternalLinks( true );
label->setTextInteractionFlags( Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse );
ImageButton* close = new ImageButton( ":/buckets/radio_clear_all_x.png" );
QHBoxLayout* h = new QHBoxLayout( label );
h->addStretch();
if (id.size())
{
label->setObjectName( id );
QProgressBar* p;
h->addWidget( p = new QProgressBar );
p->setRange( 0, 0 );
p->setFixedWidth( 90 );
}
h->addWidget( close );
h->setMargin( 4 );
label->setFixedWidth( width() );
label->adjustSize();
label->show();
ui.papyrus->move( 0, -label->height() );
doLayout();
connect( close, SIGNAL(clicked()), label, SLOT(deleteLater()) );
connect( label, SIGNAL(destroyed()), SLOT(onLabelDestroyed()), Qt::QueuedConnection );
m_timeline->setFrameRange( height(), ui.papyrus->height() );
m_timeline->start();
}
示例2: text
void tst_QProgressBar::text()
{
QProgressBar bar;
bar.setRange(10, 10);
bar.setValue(10);
QCOMPARE(bar.text(), QString("100%"));
bar.setRange(0, 10);
QCOMPARE(bar.text(), QString("100%"));
bar.setValue(5);
QCOMPARE(bar.text(), QString("50%"));
bar.setRange(0, 5);
bar.setValue(0);
bar.setRange(5, 5);
QCOMPARE(bar.text(), QString());
}
示例3: QTreeWidgetItem
void K3b::ImageWritingDialog::calculateMd5Sum( const QString& file )
{
d->haveMd5Sum = false;
if( !d->md5SumItem ) {
d->md5SumItem = new QTreeWidgetItem( d->infoView );
}
d->md5SumItem->setText( 0, i18n("MD5 Sum:") );
d->md5SumItem->setForeground( 0, d->infoTextColor );
d->md5SumItem->setTextAlignment( 0, Qt::AlignRight );
if( file != d->lastCheckedFile ) {
QProgressBar* progress = new QProgressBar( d->infoView );
progress->setMaximumHeight( fontMetrics().height() );
progress->setRange( 0, 100 );
progress->setValue( 0 );
d->infoView->setItemWidget( d->md5SumItem, 1, progress );
d->lastCheckedFile = file;
d->md5Job->setFile( file );
d->md5Job->start();
}
else
slotMd5JobFinished( true );
}
示例4: LookingForDB
void MangaW::LookingForDB(void)
{
QWidget * loadingWidget = new QWidget;
QVBoxLayout * loadingLayout = new QVBoxLayout; // Layout Vertical Box
QLabel * loadingTexte = new QLabel("Restauration des sauvegardes"); // Label = Texte
QProgressBar * loadingProgressBar = new QProgressBar; // Barre de progression
loadingProgressBar->setRange(0, 0); // ProgressBar en "chargement indéfini"
loadingLayout->addWidget(loadingTexte);
loadingLayout->addWidget(loadingProgressBar);
loadingWidget->setLayout(loadingLayout); // On ajoute le layout au Widget
loadingWidget->show(); // On affiche le widget
// On vérifie l'existance de la sauvegarde
if ( T.DB_Existe() && T.DB_Charger() )
{
loadingWidget->close();
this->ClassicStart();
}
else
{
loadingWidget->close();
this->FirstStart();
}
// ---
}
示例5: minMaxSameValue
void tst_QProgressBar::minMaxSameValue()
{
QProgressBar bar;
bar.setRange(10, 10);
bar.setValue(10);
bar.show();
}
示例6: execMaj
int Patcher::execMaj()
{
if (maj_avalible <= 0)
return 0;
QProgressBar progressBar;
progressBar.setMaximumHeight(16);
progressBar.setMaximumWidth(200);
//progressBar->setTextVisible(false);
progressBar.setRange(0,maj_avalible);
this->statusBar()->addPermanentWidget(&progressBar, 0);
this->statusBar()->showMessage(QString("Loading"));
int nb = 0;
int i = 1;
for(patcher::Maj& maj : majs)
{
this->statusBar()->showMessage(QString("download "+QString::number(i)+"/"+QString::number(maj_avalible)));
if(not maj.isDone())
nb+= maj.apply();
progressBar.setValue(++i);
}
this->statusBar()->clearMessage();
this->statusBar()->removeWidget(&progressBar);
return nb;
}
示例7: main
int main(int argc, char ** argv) {
using Q = QObject;
QApplication app{argc, argv};
QWidget ui;
QVBoxLayout layout{&ui};
QTextBrowser log;
QProgressBar bar;
QPushButton scan{"Scan localhost"};
layout.addWidget(&log);
layout.addWidget(&bar);
layout.addWidget(&scan);
bar.setRange(1, 65535);
ui.show();
Scanner scanner;
Q::connect(&scan, &QPushButton::clicked, &scanner, [&]{
scan.setEnabled(false);
scanner.start();
});
Q::connect(&scanner, &Scanner::hasResult, &log, [&](int port, bool isOpen){
bar.setValue(port);
if (!isOpen) return;
auto color = isOpen ? QStringLiteral("green") : QStringLiteral("red");
auto state = isOpen ? QStringLiteral("open") : QStringLiteral("closed");
log.append(QStringLiteral("<font color=\"%1\">Port %2 is %3.</font><br/>").
arg(color).arg(port).arg(state));
});
Q::connect(&scanner, &Scanner::done, &scan, [&]{
bar.reset();
scan.setEnabled(true);
});
return app.exec();
}
示例8: backup
void BackupDialog::backup()
{
QDir dir;
// Compute a default file name & path (eg. "Baskets_2007-01-31.tar.gz"):
KConfig *config = KGlobal::config().data();
KConfigGroup configGroup(config, "Backups");
QString folder = configGroup.readEntry("lastFolder", QDir::homePath()) + "/";
QString fileName = i18np("Backup filename (without extension), %1 is the date", "Baskets_%1", QDate::currentDate().toString(Qt::ISODate));
QString url = folder + fileName;
// Ask a file name & path to the user:
QString filter = "*.tar.gz|" + i18n("Tar Archives Compressed by Gzip") + "\n*|" + i18n("All Files");
QString destination = url;
for (bool askAgain = true; askAgain;) {
// Ask:
destination = KFileDialog::getSaveFileName(destination, filter, 0, i18n("Backup Baskets"));
// User canceled?
if (destination.isEmpty())
return;
// File already existing? Ask for overriding:
if (dir.exists(destination)) {
int result = KMessageBox::questionYesNoCancel(
0,
"<qt>" + i18n("The file <b>%1</b> already exists. Do you really want to override it?",
KUrl(destination).fileName()),
i18n("Override File?"),
KGuiItem(i18n("&Override"), "document-save")
);
if (result == KMessageBox::Cancel)
return;
else if (result == KMessageBox::Yes)
askAgain = false;
} else
askAgain = false;
}
KProgressDialog dialog(0, i18n("Backup Baskets"), i18n("Backing up baskets. Please wait..."));
dialog.setModal(true);
dialog.setAllowCancel(false);
dialog.setAutoClose(true);
dialog.show();
QProgressBar *progress = dialog.progressBar();
progress->setRange(0, 0/*Busy/Undefined*/);
progress->setValue(0);
progress->setTextVisible(false);
BackupThread thread(destination, Global::savesFolder());
thread.start();
while (thread.isRunning()) {
progress->setValue(progress->value() + 1); // Or else, the animation is not played!
kapp->processEvents();
usleep(300); // Not too long because if the backup process is finished, we wait for nothing
}
Settings::setLastBackup(QDate::currentDate());
Settings::saveConfig();
populateLastBackup();
}
示例9: onLoadStarted
void BrowserView::onLoadStarted()
{
QProgressBar* bar = Gui::Sequencer::instance()->getProgressBar();
bar->setRange(0, 100);
bar->show();
Gui::getMainWindow()->showMessage(tr("Loading %1...").arg(view->url().toString()));
isLoading = true;
}
示例10: appendProgress
void MessageDisplayWidget::appendProgress(const QString &filename, FileTransferState* state, bool isOur)
{
connect(verticalScrollBar(), &QScrollBar::rangeChanged, this, &MessageDisplayWidget::moveScrollBarToBottom, Qt::UniqueConnection);
QProgressBar *row = new QProgressBar(this);
row->setRange(0, 100);
row->setFormat(QString("%1 - %p%").arg(QFileInfo(filename).baseName()));
connect(state, &FileTransferState::progressChanged, row, &QProgressBar::setValue);
mainlayout->addWidget(row);
}
示例11: formatedText
void tst_QProgressBar::formatedText()
{
QFETCH(int, minimum);
QFETCH(int, maximum);
QFETCH(int, value);
QFETCH(QString, format);
QFETCH(QString, text);
QProgressBar bar;
bar.setRange(minimum, maximum);
bar.setValue(value);
bar.setFormat(format);
QCOMPARE(bar.text(), text);
}
示例12: updateResolverPool
/**
* @brief Updates the resolver pool display.
*/
void OpenNIC::updateResolverPool(QStringList resolverPool)
{
/* @brief <status>;<score>;<kind>;<hostAddress>; */
QTableWidget* table = ui->resolverPoolTable;
double minScore,maxScore;
scoreMinMax(resolverPool, minScore, maxScore);
table->setRowCount(resolverPool.count());
for(int row=0; row < resolverPool.count(); row++ )
{
QStringList elements = resolverPool.at(row).split(";");
QString ip = elements.at(3);
QString kind = elements.at(2);
QString score = elements.at(1);
QString status = elements.at(0);
QString statusIcon;
if (status == "R")
{
status = tr("FAIL");
statusIcon = ":/images/status-red.png";
}
else if (status == "G")
{
status = tr("OK");
statusIcon = ":/images/status-green.png";
}
else if (status == "Y")
{
status = tr("WARN");
statusIcon = ":/images/status-yellow.png";
}
table->setItem(row,3,new QTableWidgetItem(ip));
table->setItem(row,2,new QTableWidgetItem(kind));
#if 0
table->setItem(row,1,new QTableWidgetItem(score));
#else
QProgressBar* bar = new QProgressBar();
bar->setRange((int)(minScore*1000.0),(int)(maxScore*1000.0));
bar->setValue((int)(score.toDouble()*1000.0));
table->setCellWidget(row,1,bar);
#endif
table->setItem(row,0,new QTableWidgetItem(QIcon(statusIcon),status));
}
table->resizeColumnsToContents();
table->resizeRowsToContents();
table->setSortingEnabled(true);
table->sortByColumn(1,Qt::DescendingOrder);
}
示例13: execFinished
ProgressUI::ProgressUI(QWidget *parent)
: THWidgetBase(parent)
{
timerId = -1;
gradient = 0;
hideTitleBar();
setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint | Qt::Tool);
setWindowModality(Qt::ApplicationModal);
QVBoxLayout *v = new QVBoxLayout(this);
v->setContentsMargins(5, 5, 5, 5);
v->setSpacing(0);
lbl = new QLabel(this);
lbl->setStyleSheet(QStringLiteral("font-family:΢ÈíÑźÚ;font:12px;color:white;"));
QProgressBar *pbar = new QProgressBar(this);
pbar->setRange(0, 100);
pbar->setValue(0);
pbar->setFixedSize(260, 12);
QFile file;
file.setFileName(":res/css/progressbar.css");
if (file.open(QIODevice::ReadOnly))
{
QByteArray ba = file.readAll();
pbar->setStyleSheet(QTextCodec::codecForLocale()->toUnicode(ba));
}
file.close();
v->addWidget(lbl, 1, Qt::AlignCenter);
v->addWidget(pbar, 1, Qt::AlignCenter);
setFixedSize(280, 50);
connect(this, &ProgressUI::setValue, pbar, [=] (int value) {
pbar->setValue(value);
if (pbar->value() >= 100)
{
lbl->setText(QStringLiteral("Íê³É"));
emit execFinished();
QTimer::singleShot(1000, this, [=] () {
disconnect(this, 0, 0, 0);
this->close();
this->deleteLater();
});
}
});
timerId = startTimer(60/*, Qt::VeryCoarseTimer*/);
}
示例14: setProgress
void CalculateAmplitudes::setProgress(int row, int progress) {
QProgressBar *progressBar = static_cast<QProgressBar*>(_ui.table->cellWidget(row, 3));
_ui.table->setItem(row, 3, NULL);
if ( !progressBar ) {
progressBar = new QProgressBar(_ui.table);
progressBar->setRange(0, 100);
progressBar->setAlignment(Qt::AlignHCenter);
QPalette pal = progressBar->palette();
pal.setColor(QPalette::Highlight, Qt::darkGreen);
progressBar->setPalette(pal);
_ui.table->setCellWidget(row, 3, progressBar);
}
progressBar->setValue(progress);
filterView(row, 1);
}
示例15: tr
UpdaterDialog::UpdaterDialog() :
QProgressDialog("", tr("Cancel"), 0, 0)
{
setWindowTitle(tr("Updater - Lightscreen"));
setWindowFlags(windowFlags() ^ Qt::WindowContextHelpButtonHint);
setAutoClose(false);
QProgressBar *bar = new QProgressBar(this);
bar->setTextVisible(false);
bar->setRange(0, 0);
QLabel *label = new QLabel(tr("Checking for updates"), this);
connect(label, SIGNAL(linkActivated(QString)), this, SLOT(link(QString)));
setLabel(label);
setBar(bar);
}