本文整理汇总了C++中ProgressBar::setFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgressBar::setFormat方法的具体用法?C++ ProgressBar::setFormat怎么用?C++ ProgressBar::setFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgressBar
的用法示例。
在下文中一共展示了ProgressBar::setFormat方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: format
void tst_QProgressBar::format()
{
ProgressBar bar;
bar.setRange(0, 10);
bar.setValue(1);
bar.show();
QTest::qWaitForWindowShown(&bar);
QTest::qWait(20);
bar.repainted = false;
bar.setFormat("%v of %m (%p%)");
QTest::qWait(20);
QTRY_VERIFY(bar.repainted);
bar.repainted = false;
bar.setFormat("%v of %m (%p%)");
qApp->processEvents();
#ifndef Q_WS_MAC
// Animated scroll bars get paint events all the time
#ifdef Q_OS_WIN
if (QSysInfo::WindowsVersion < QSysInfo::WV_VISTA)
#endif
QVERIFY(!bar.repainted);
#endif
QCOMPARE(bar.text(), QString("1 of 10 (10%)"));
bar.setRange(5, 5);
bar.setValue(5);
QCOMPARE(bar.text(), QString("5 of 0 (100%)"));
bar.setRange(0, 5);
bar.setValue(0);
bar.setRange(5, 5);
QCOMPARE(bar.text(), QString());
}
示例2: setMinMaxRepaint
void tst_QProgressBar::setMinMaxRepaint()
{
ProgressBar pbar;
pbar.setMinimum(0);
pbar.setMaximum(10);
pbar.setFormat("%v");
pbar.show();
QVERIFY(QTest::qWaitForWindowActive(&pbar));
// No repaint when setting minimum to the current minimum
pbar.repainted = false;
pbar.setMinimum(0);
QTest::qWait(50);
QTRY_VERIFY(!pbar.repainted);
// No repaint when setting maximum to the current maximum
pbar.repainted = false;
pbar.setMaximum(10);
QTest::qWait(50);
QTRY_VERIFY(!pbar.repainted);
// Repaint when setting minimum
for (int i = 9; i >= 0; i--) {
pbar.repainted = false;
pbar.setMinimum(i);
QTRY_VERIFY(pbar.repainted);
}
// Repaint when setting maximum
for (int i = 0; i < 10; ++i) {
pbar.repainted = false;
pbar.setMaximum(i);
QTRY_VERIFY(pbar.repainted);
}
}
示例3: setValueRepaint
void tst_QProgressBar::setValueRepaint()
{
ProgressBar pbar;
pbar.setMinimum(0);
pbar.setMaximum(10);
pbar.setFormat("%v");
pbar.show();
QTest::qWaitForWindowShown(&pbar);
QApplication::processEvents();
for (int i = pbar.minimum(); i < pbar.maximum(); ++i) {
pbar.repainted = false;
pbar.setValue(i);
QTest::qWait(50);
QTRY_VERIFY(pbar.repainted);
}
}