예제 #1
0
  MainFrame()
    : Dialog("ProgressBars")
    , m_progressBar1(this)
    , m_progressBar2(this, ProgressBarStyle + SmoothProgressBarStyle)
    , m_start("Start", this)
    , m_close("Close", this)
  {
    // a box layout manager with vertical orientation and no-homogeneous
    setLayout(new BoxLayout(Orientation::Vertical, false));

    // set the ranges of the progress bars
    m_progressBar1.setRange(0, 100);
    m_progressBar2.setRange(0, 100);

    // the "Start" button is the default one
    m_start.setDefault(true);

    // call "onStart" when the "Start" button is pressed
    m_start.Action.connect(Bind(&MainFrame::onStart, this));

    // the defaultCancelAction of dialogs generates an "WM_CLOSE"
    // message that is converted to the "onClose" event
    m_close.Action.connect(Bind(&MainFrame::defaultCancelAction, this));

    // the application is waiting to work (the user should press the
    // "Start" button)
    m_state = WaitingToWork;

    // set the size of the Frame
    setSize(Size(256, getPreferredSize().h));
    center();
  }
예제 #2
0
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());
}
예제 #3
0
파일: ProgressBars.cpp 프로젝트: Jmos/vaca
  MainFrame()
    : Dialog(L"ProgressBars")
    , m_progressBar1(this)
    , m_progressBar2(this, ProgressBar::Styles::Default +
			   ProgressBar::Styles::Smooth)
    , m_progressBar3(this, ProgressBar::Styles::Default +
			   ProgressBar::Styles::Marquee)
    , m_start(L"Start", this)
    , m_close(L"Close", this)
  {
    // a box layout manager with vertical orientation and no-homogeneous
    setLayout(new BoxLayout(Orientation::Vertical, false));

    // set the ranges of the progress bars
    m_progressBar1.setRange(0, 100);
    m_progressBar2.setRange(0, 100);
    m_progressBar3.setMarquee(0);

    // the "Start" button is the default one
    m_start.setDefault(true);

    // call "onStart" when the "Start" button is pressed
    m_start.Click.connect(Bind(&MainFrame::onStart, this));

    // the Dialog::onCancel generates an onClose event
    m_close.Click.connect(Bind(&MainFrame::onCancel, this));

    // the application is waiting to work (the user should press the
    // "Start" button)
    m_state = WaitingToWork;

    // set the size of the Frame
    setSize(Size(256, getPreferredSize().h));
    center();
  }