本文整理汇总了C++中QScrollBar::setRange方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollBar::setRange方法的具体用法?C++ QScrollBar::setRange怎么用?C++ QScrollBar::setRange使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollBar
的用法示例。
在下文中一共展示了QScrollBar::setRange方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QCOMPARE
void tst_QAbstractScrollArea::setScrollBars2()
{
QAbstractScrollArea scrollArea;
scrollArea.resize(300, 300);
QScrollBar *hbar = new QScrollBar;
scrollArea.setHorizontalScrollBar(hbar);
qApp->processEvents();
QCOMPARE(scrollArea.horizontalScrollBar(), hbar);
QScrollBar *vbar = new QScrollBar;
scrollArea.setVerticalScrollBar(vbar);
qApp->processEvents();
QCOMPARE(scrollArea.verticalScrollBar(), vbar);
scrollArea.horizontalScrollBar()->setRange(0, 100);
scrollArea.verticalScrollBar()->setRange(0, 100);
scrollArea.show();
// Make sure scroll bars are not explicitly hidden by QAbstractScrollArea itself.
QVERIFY(hbar->isVisible());
QVERIFY(vbar->isVisible());
// Hide the OLD scroll bar and ensure that the NEW one is hidden.
hbar->hide();
scrollArea.setHorizontalScrollBar(new QScrollBar);
qApp->processEvents();
QVERIFY(!scrollArea.horizontalScrollBar()->isVisible());
vbar->hide();
scrollArea.setVerticalScrollBar(new QScrollBar);
qApp->processEvents();
QVERIFY(!scrollArea.verticalScrollBar()->isVisible());
scrollArea.verticalScrollBar()->show();
scrollArea.horizontalScrollBar()->show();
// Hide the NEW scroll bar and ensure that it's visible
// (because the OLD one is visible).
hbar = new QScrollBar;
hbar->hide();
scrollArea.setHorizontalScrollBar(hbar);
qApp->processEvents();
QVERIFY(hbar->isVisible());
vbar = new QScrollBar;
vbar->hide();
scrollArea.setVerticalScrollBar(vbar);
qApp->processEvents();
QVERIFY(vbar->isVisible());
vbar->setRange(0, 0);
qApp->processEvents();
QVERIFY(!vbar->isVisible());
hbar->setRange(0, 0);
qApp->processEvents();
QVERIFY(!hbar->isVisible());
}
示例2: updateScrollBars
void TailView::updateScrollBars(int newMax)
{
if(verticalScrollBar()->maximum() != newMax) {
QScrollBar * vsb = verticalScrollBar();
vsb->setRange(0, newMax);
vsb->setPageStep(numLinesOnScreen() - PAGE_STEP_OVERLAP);
vsb->setSingleStep(1);
}
}
示例3: getNativeObject
/*
* Setvalues.
*/
JNIEXPORT void JNICALL Java_gnu_java_awt_peer_qt_QtScrollbarPeer_setValues
(JNIEnv *env, jobject obj, jint value, jint visible, jint min, jint max)
{
QScrollBar *bar = (QScrollBar *) getNativeObject( env, obj );
assert( bar );
bar->setValue(value);
bar->setPageStep( visible ); // page step and slider size are the same in Qt
bar->setRange( min , max );
}
示例4: setSlaveLayout
void EigenGraspDlg::setSlaveLayout( int nGrasps )
{
mainLayout = new QVBoxLayout(mSlave, 5);
QLabel *valueLabel = new QLabel(QString("Value:"), mSlave);
QLabel *amplLabel = new QLabel(QString("Amplitude:"), mSlave);
QLabel *fixedLabel = new QLabel(QString("Fixed"), mSlave);
QHBoxLayout *fakeRow = new QHBoxLayout(mainLayout,-1);
fakeRow->addSpacing(400);
QHBoxLayout *labelRow = new QHBoxLayout(mainLayout,-1);
labelRow->addSpacing(5);
labelRow->addWidget(valueLabel,0);
labelRow->addWidget(amplLabel,1,Qt::AlignHCenter);
labelRow->addWidget(fixedLabel,0);
labelRow->addSpacing(5);
mainLayout->addLayout(labelRow);
for (int i=0; i<nGrasps; i++) {
QHBoxLayout *graspRow = new QHBoxLayout(mainLayout,10);
QLabel *eigenValue = new QLabel(QString("0.0"), mSlave);
QScrollBar *bar = new QScrollBar(Qt::Horizontal, mSlave);
bar->setRange( -SLIDER_STEPS, SLIDER_STEPS );
bar->setPageStep(5000);
bar->setLineStep(1000);
bar->setValue(0);
QCheckBox *box = new QCheckBox(mSlave);
graspRow->addSpacing(15);
graspRow->addWidget(eigenValue,0);
graspRow->addWidget(bar,1);
graspRow->addWidget(box,0);
graspRow->addSpacing(15);
mValueList.push_back(eigenValue);
mBarList.push_back(bar);
mCheckList.push_back(box);
connect(bar,SIGNAL(sliderMoved(int)), this, SLOT(eigenGraspChanged()) );
//comment this one out
//connect(bar,SIGNAL(valueChanged(int)), this, SLOT(eigenGraspChanged()) );
connect(bar,SIGNAL(nextLine()), this, SLOT(eigenGraspChanged()) );
connect(bar,SIGNAL(prevLine()), this, SLOT(eigenGraspChanged()) );
connect(bar,SIGNAL(nextPage()), this, SLOT(eigenGraspChanged()) );
connect(bar,SIGNAL(prevPage()), this, SLOT(eigenGraspChanged()) );
connect(bar,SIGNAL(sliderReleased()), this, SLOT(eigenGraspChanged()) );
connect(box,SIGNAL(clicked()), this, SLOT(fixBoxChanged()) );
}
mainLayout->addSpacing(20);
}
示例5: QScrollBar
/*!
\internal
Reimplemented from the QtAbstractEditorFactory class.
*/
QWidget *QtLongScrollBarFactory::createEditor(QtLongPropertyManager *manager, QtProperty *property,
QWidget *parent)
{
QScrollBar *editor = new QScrollBar(Qt::Horizontal, parent);
d_ptr->initializeEditor(property, editor);
editor->setSingleStep(manager->singleStep(property));
editor->setRange(manager->minimum(property), manager->maximum(property));
editor->setValue(manager->value(property));
connect(editor, SIGNAL(valueChanged(long)), this, SLOT(slotSetValue(long)));
connect(editor, SIGNAL(destroyed(QObject *)),
this, SLOT(slotEditorDestroyed(QObject *)));
return editor;
}
示例6: slotRangeChanged
void QtScrollBarFactory::slotRangeChanged(QtProperty *property, int min, int max)
{
if (!m_createdEditors.contains(property))
return;
QtIntPropertyManager *manager = this->propertyManager(property);
if (!manager)
return;
QListIterator<QScrollBar *> itEditor( m_createdEditors[property]);
while (itEditor.hasNext()) {
QScrollBar *editor = itEditor.next();
editor->blockSignals(true);
editor->setRange(min, max);
editor->setValue(manager->value(property));
editor->blockSignals(false);
}
}
示例7: drawCharacters
void Scene::drawCharacters(QList<Character> characters, int z)
{
//Draw scrollbar to browse Characters if more then 5 Characters
QScrollBar *scrollcharacters = new QScrollBar(Qt::Horizontal);
if(characters.count() > max_characters_on_screen_)
{
scrollcharacters->setGeometry(0, this->height()*29/30, this->width(), this->height()/30);
scrollcharacters->setRange(0, this->width()/(max_characters_on_screen_ + 1));
addWidget(scrollcharacters);
}
else
scrollcharacters = NULL;
//Draw Characters
int position = 1;
foreach(Character p, characters)
{
drawCharacter(p, position, z, characters.count(), scrollcharacters);
position += 1;
}
示例8: updateScrollBar
void MainWindow::updateScrollBar( bool blockSignals )
{
QScrollBar* sb = ui->horizontalScrollBar;
if ( PlotsArea==NULL || !PlotsArea->isZoomed() )
{
sb->hide();
}
else
{
const FrameInterval intv = PlotsArea->visibleFrames();
sb->blockSignals( blockSignals );
sb->setRange( 0, PlotsArea->numFrames() - intv.count() + 1 );
sb->setValue( intv.from );
sb->setPageStep( intv.count() );
sb->setSingleStep( intv.count() );
sb->blockSignals( false );
sb->show();
}
}
示例9: embeddedDocTxt
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent), ui(new Ui::MainWindow),
logNewMessages(0), logHasErrors(false), showNewLogNumber(true)
{
ui->setupUi(this);
setWindowIcon(QIcon(c_icon_app));
setWindowTitle(c_qtau_name);
setAcceptDrops(true);
setContextMenuPolicy(Qt::NoContextMenu);
//-----------------------------------------
QLabel *meterLabel = new QLabel(QString("%1/%2") .arg(ns.notesInBar).arg(ns.noteLength), this);
QLabel *tempoLabel = new QLabel(QString("%1 %2").arg(ns.tempo).arg(tr("bpm")), this);
QHBoxLayout *bpmHBL = new QHBoxLayout();
bpmHBL->setContentsMargins(0,0,0,0);
bpmHBL->addSpacing(5);
bpmHBL->addWidget(meterLabel);
bpmHBL->addWidget(tempoLabel);
bpmHBL->addSpacing(5);
QFrame *tempoPanel = new QFrame(this);
tempoPanel->setMinimumSize(c_piano_min_width, c_meter_min_height);
tempoPanel->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum);
tempoPanel->setContentsMargins(1,0,1,1);
tempoPanel->setFrameStyle(QFrame::Panel | QFrame::Raised);
tempoPanel->setLayout(bpmHBL);
meter = new qtauMeterBar(this);
meter->setMinimumHeight(c_meter_min_height);
meter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
meter->setContentsMargins(0,0,0,0);
piano = new qtauPiano(ui->centralWidget);
piano->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
piano->setMinimumSize(c_piano_min_width, c_piano_min_height);
piano->setContentsMargins(0,0,0,0);
zoom = new QSlider(Qt::Horizontal, ui->centralWidget);
zoom->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Preferred);
zoom->setRange(0, c_zoom_num - 1);
zoom->setSingleStep(1);
zoom->setPageStep(1);
zoom->setValue(cdef_zoom_index);
zoom->setMinimumWidth(c_piano_min_width);
zoom->setGeometry(0,0,c_piano_min_width,10);
zoom->setContentsMargins(0,0,0,0);
noteEditor = new qtauNoteEditor(ui->centralWidget);
noteEditor->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
noteEditor->setContentsMargins(0,0,0,0);
hscr = new QScrollBar(Qt::Horizontal, ui->centralWidget);
vscr = new QScrollBar(Qt::Vertical, ui->centralWidget);
hscr->setContentsMargins(0,0,0,0);
vscr->setContentsMargins(0,0,0,0);
hscr->setRange(0, ns.note.width() * ns.notesInBar * cdef_bars);
vscr->setRange(0, ns.note.height() * 12 * ns.numOctaves);
hscr->setSingleStep(ns.note.width());
vscr->setSingleStep(ns.note.height());
hscr->setContextMenuPolicy(Qt::NoContextMenu);
vscr->setContextMenuPolicy(Qt::NoContextMenu);
//---- vocal and music waveform panels, hidden until synthesized (vocal wave) and/or loaded (music wave)
QScrollBar *dummySB = new QScrollBar(this);
dummySB->setOrientation(Qt::Vertical);
dummySB->setRange(0,0);
dummySB->setEnabled(false);
QFrame *vocalControls = new QFrame(this);
vocalControls->setContentsMargins(0,0,0,0);
vocalControls->setMinimumSize(c_piano_min_width, c_waveform_min_height);
vocalControls->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Expanding);
vocalControls->setFrameStyle(QFrame::Panel | QFrame::Raised);
vocalWave = new qtauWaveform(this);
vocalWave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
vocalWave->setMinimumHeight(c_waveform_min_height);
vocalWave->setContentsMargins(0,0,0,0);
QHBoxLayout *vocalWaveL = new QHBoxLayout();
vocalWaveL->setContentsMargins(0,0,0,0);
vocalWaveL->setSpacing(0);
vocalWaveL->addWidget(vocalControls);
vocalWaveL->addWidget(vocalWave);
vocalWaveL->addWidget(dummySB);
vocalWavePanel = new QWidget(this);
vocalWavePanel->setContentsMargins(0,0,0,0);
vocalWavePanel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
vocalWavePanel->setLayout(vocalWaveL);
vocalWavePanel->setVisible(false);
//---------
//.........这里部分代码省略.........
示例10: QMainWindow
ReportList::ReportList(BoxType type, bool sortByScore, QWidget *parent)
: QMainWindow(parent)
{
this->sort = sortByScore;
printAction = new QAction("&Print...", this);
QMenu* fileMenu = menuBar()->addMenu("&File");
fileMenu->addAction(printAction);
connect(printAction, SIGNAL(triggered()), this, SLOT(print()));
QWidget* central = new QWidget();
this->setCentralWidget(central);
QHBoxLayout* mainLayout = new QHBoxLayout();
central->setLayout(mainLayout);
this->reports = new QStackedWidget();
int size = 0;
if(type == employee)
{
employeeData = DataInterface::getEmployees();
if(sortByScore)
{
this->setWindowTitle("Employee View - Sorted By Average Score");
qSort(employeeData.begin(), employeeData.end());
} else
{
this->setWindowTitle("Employee View");
}
size = employeeData.size();
for(int i = 0; i < size; i++)
{
EmployeeReportBox* box = new EmployeeReportBox(employeeData.at(i), i, size);
reports->addWidget(box);
}
} else if(type == employer)
{
this->setWindowTitle("Employer View");
employerData = DataInterface::getEmployers();
size = employerData.size();
for(int i = 0; i < size; i++)
{
EmployerReportBox* box = new EmployerReportBox(employerData.at(i), i, size);
reports->addWidget(box);
}
} else
{
QMessageBox::information(this, "Failed To Read Data", "Failed to read the data from the file.");
return;
}
QScrollBar *scrollBar = new QScrollBar(Qt::Vertical);
scrollBar->setRange(0, size - 1);
scrollBar->setValue(0);
scrollBar->setFocusPolicy(Qt::WheelFocus);
connect(scrollBar, SIGNAL(valueChanged(int)), this, SLOT(moveToBox(int)));
this->setFixedHeight(370);
reports->setCurrentIndex(0);
mainLayout->addWidget(reports);
mainLayout->addWidget(scrollBar);
}