本文整理汇总了C++中QScrollBar::setMaximum方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollBar::setMaximum方法的具体用法?C++ QScrollBar::setMaximum怎么用?C++ QScrollBar::setMaximum使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollBar
的用法示例。
在下文中一共展示了QScrollBar::setMaximum方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateScrollBar
void QConsolePrivate::updateScrollBar (void)
{
m_scrollBar->setMinimum (0);
if (m_bufferSize.height () > m_consoleRect.height ())
m_scrollBar->setMaximum (m_bufferSize.height () - m_consoleRect.height ());
else
m_scrollBar->setMaximum (0);
m_scrollBar->setSingleStep (1);
m_scrollBar->setPageStep (m_consoleRect.height ());
m_scrollBar->setValue (m_consoleRect.top ());
log ("Scrollbar parameters updated: %d/%d/%d/%d\n",
m_scrollBar->minimum (), m_scrollBar->maximum (),
m_scrollBar->singleStep (), m_scrollBar->pageStep ());
}
示例2: moveDown
void TocDlg::moveDown() {
if(isPageUpdated) {
on_actionUpdatePage_triggered();
isPageUpdated = false;
}
int cur_num = getCurrentItemPosFromBegin(m_docview->getToc(),m_ui->treeWidget->currentItem(), 0);
int r_num = getMaxItemPosFromBegin(m_docview->getToc(),m_ui->treeWidget->currentItem(),0);
QScrollBar * scrollBar = m_ui->treeWidget->verticalScrollBar();
// для отладки
if((cur_num>=(curPage*pageStrCount)) || (cur_num==r_num)){
// first page
if(curPage+1>pageCount){
curPage=1;
scrollBar->setValue(0);
updateTitle();
return;
}
// next page
if(curPage+1<=pageCount) {
curPage+=1;
scrollBar->setMaximum((pageCount-1) * pageStrCount);
scrollBar->setValue(curPage*pageStrCount-pageStrCount);
updateTitle();
}
}
}
示例3: moveUp
void TocDlg::moveUp(){
if(isPageUpdated) {
on_actionUpdatePage_triggered();
isPageUpdated = false;
}
int cur_num = getCurrentItemPosFromBegin(m_docview->getToc(),m_ui->treeWidget->currentItem(), 0);
QScrollBar * scrollBar = m_ui->treeWidget->verticalScrollBar();
// для отладки
if((cur_num<=((curPage-1)*pageStrCount)+1) || (cur_num==1)){
// last page
if((curPage-1)==0){
curPage=pageCount;
scrollBar->setMaximum((pageCount-1) * pageStrCount);
scrollBar->setValue(curPage*pageStrCount-pageStrCount);
updateTitle();
////break;
return;
}
// previous page
if(curPage-1>=1) {
curPage-=1;
scrollBar->setValue(scrollBar->value()-pageStrCount);
updateTitle();
}
}
}
示例4: eventFilter
bool RecentBooksDlg::eventFilter(QObject *obj, QEvent *event)
{
if(event->type() == QEvent::KeyPress) {
QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
QString text;
switch(keyEvent->key()) {
case Qt::Key_Up:
if(obj == m_ui->tableWidget) {
QScrollBar * scrollBar = m_ui->tableWidget->verticalScrollBar();
int pageStrCount = scrollBar->pageStep();
int fullStrCount = scrollBar->maximum()-scrollBar->minimum()+pageStrCount;
if(fullStrCount==pageStrCount) {
pageCount = 1;
//return;
}
if(pageStrCount==1) {
scrollBar->setMaximum(fullStrCount*2);
pageStrCount = scrollBar->pageStep();
}
pageCount = ceil((double)fullStrCount/pageStrCount);
if(((m_ui->tableWidget->currentRow()+1)/2 == 1) && (pageStrCount/2>1)){
}
}
break;
return true;
}
}
return false;
}
示例5: paintEvent
///Generates renderObjectCollections when required, i.e.
///when re-sized, molecule altered; adjusts the vertical scrollbar,
///and paints all visible renderOjbectCollections
void RenderArea::paintEvent(QPaintEvent *)
{
//First, let's see how big the window is and how many bases we can spanIdRole
QFont font("Courier", 14, QFont::Normal); //need fixed width font
QPainter painter(viewport());
painter.setFont(font);
QFontMetrics fm(font);
int charWidth = fm.width("cagtnrlpyt") / 10; //width of each cha
int lineHeight = charWidth*3; //fm.height("cagtnrlpyt");
int numberWidth = round(log10(pMol->sequence.length())) * charWidth + charWidth ;
int basePerLine = (width()-numberWidth-32)/charWidth;
int currentBase = 0;
QString number = QString();
QScrollBar* scrollbar = verticalScrollBar();
//we go here and re-virtual-render everything if the window has been re-sized
//as well as adjusting the vertical scroll bar
if (reSized)
{
float r = ((float) scrollbar->sliderPosition())/((float) totalHeight); //get relative position of where we are
while (!renderObjects.isEmpty()) delete renderObjects.takeFirst(); //clean up previous render Elements
totalHeight = 0; //clear cumulative height
do {
qDebug() << "---------Line----------" << currentBase;
RenderObjectContainer* container = pMol->renderSequenceDump(NULL, currentBase,currentBase+basePerLine, charWidth);
renderObjects.append(container);
currentBase += basePerLine;
totalHeight+=container->rect.height(); //measure total height of render
} while ((currentBase + basePerLine)<(pMol->sequence.length()));
scrollbar->setMinimum(1); //re-set the scrollbar
scrollbar->setMaximum(totalHeight-height()+100); //leave a bit of room at the bottom
scrollbar->setPageStep(height()); //adjust the page step to the view port's size
scrollbar->setSliderPosition(round(r*totalHeight)); //set the slider position correctly from the relative value we had stored
scrollbar->setSingleStep(charWidth);
reSized = false; //label as reSized!
}
//This bit paints only the renderObjectContainers above that are visible on this viewport
int y = 1; //renderObjects.at(1)->rect.height();
int virtualy = scrollbar->sliderPosition();
for (int i = 0; i < renderObjects.size(); ++i) //ok let's paint what is visible in the view-port
{
y+= renderObjects.at(i)->rect.height();
if (y>=virtualy) renderObjects.at(i)->Render(&painter, numberWidth, y-virtualy); //only if visible
if (y>(virtualy + height())) break; //if over the edge of the view port, stop looping
}
}
示例6: movePage
void TocDlg::movePage()
{
Device::forceFullScreenUpdate();
QScrollBar * scrollBar = m_ui->treeWidget->verticalScrollBar();
scrollBar->setMaximum((pageCount-1) * pageStrCount);
scrollBar->setValue(curPage*pageStrCount-pageStrCount);
// code added 28.11.2011
setCurrentItemFirstInPage(curPage,m_docview->getToc(),m_ui->treeWidget->currentItem(),0);
updateTitle();
}
示例7: ModifyScrollBars
// Set the extent of the vertical and horizontal scrollbars and return true if
// the view needs re-drawing.
bool QsciScintillaQt::ModifyScrollBars(int nMax,int nPage)
{
bool modified = false;
QScrollBar *sb;
int vNewPage = nPage;
int vNewMax = nMax - vNewPage + 1;
if (vMax != vNewMax || vPage != vNewPage)
{
vMax = vNewMax;
vPage = vNewPage;
modified = true;
sb = qsb->verticalScrollBar();
sb->setMaximum(vMax);
sb->setPageStep(vPage);
}
int hNewPage = GetTextRectangle().Width();
int hNewMax = (scrollWidth > hNewPage) ? scrollWidth - hNewPage : 0;
int charWidth = vs.styles[STYLE_DEFAULT].aveCharWidth;
sb = qsb->horizontalScrollBar();
if (hMax != hNewMax || hPage != hNewPage || sb->singleStep() != charWidth)
{
hMax = hNewMax;
hPage = hNewPage;
modified = true;
sb->setMaximum(hMax);
sb->setPageStep(hPage);
sb->setSingleStep(charWidth);
}
return modified;
}
示例8: consoleView
ConsoleWidget::ConsoleWidget(ConsoleView& consoleView, ConsoleRoboCupCtrl& console, QString& output, ConsoleWidget*& consoleWidget) :
consoleView(consoleView), console(console), output(output), consoleWidget(consoleWidget),
canCopy(false), canUndo(false), canRedo(false)
{
setFrameStyle(QFrame::NoFrame);
setAcceptRichText(false);
bool restoredCursor = false;
if(consoleView.loadAndSaveOutput)
{
QSettings& settings = RoboCupCtrl::application->getLayoutSettings();
settings.beginGroup(consoleView.fullName);
output = settings.value("Output").toString();
setPlainText(output);
output.clear();
int selectionStart = settings.value("selectionStart").toInt();
int selectionEnd = settings.value("selectionEnd").toInt();
if(selectionStart || selectionEnd)
{
QTextCursor cursor = textCursor();
cursor.setPosition(selectionStart);
cursor.setPosition(selectionEnd, QTextCursor::KeepAnchor);
setTextCursor(cursor);
restoredCursor = true;
}
QScrollBar* scrollBar = verticalScrollBar();
scrollBar->setMaximum(settings.value("verticalScrollMaximum").toInt());
scrollBar->setValue(settings.value("verticalScrollPosition").toInt());
settings.endGroup();
}
else
{
setPlainText(output);
output.clear();
}
if(!restoredCursor)
{
QTextCursor cursor = textCursor();
cursor.movePosition(QTextCursor::End, QTextCursor::MoveAnchor);
setTextCursor(cursor);
}
connect(this, SIGNAL(copyAvailable(bool)), this, SLOT(copyAvailable(bool)));
connect(this, SIGNAL(undoAvailable(bool)), this, SLOT(undoAvailable(bool)));
connect(this, SIGNAL(redoAvailable(bool)), this, SLOT(redoAvailable(bool)));
}
示例9: fillOpts
void TocDlg::fillOpts()
{
QScrollBar * scrollBar = m_ui->treeWidget->verticalScrollBar();
pageStrCount = scrollBar->pageStep();
fullStrCount = scrollBar->maximum()-scrollBar->minimum()+pageStrCount;
if(fullStrCount==pageStrCount) {
pageCount = 1;
return;
}
if(pageStrCount==1) {
scrollBar->setMaximum(fullStrCount*2);
pageStrCount = scrollBar->pageStep();
}
pageCount = ceil((double)fullStrCount/pageStrCount);
}
示例10: setCurrentItemPage
void TocDlg::setCurrentItemPage()
{
if(isPageUpdated) {
on_actionUpdatePage_triggered();
isPageUpdated = false;
}
QScrollBar * scrollBar = m_ui->treeWidget->verticalScrollBar();
int nearest_Page = getCurrentItemPage();
if((curPage!=nearest_Page) && (nearest_Page>1)){
if((nearest_Page==pageCount) && (pageCount>1)) {
curPage=pageCount-1;
scrollBar->setValue(scrollBar->value()-pageStrCount);
updateTitle();
}
// тут ошибка непонятная возникает с позиционированием скролбара на последней странице
curPage = nearest_Page;
scrollBar->setMaximum((pageCount-1) * pageStrCount);
scrollBar->setValue(curPage*pageStrCount-pageStrCount);
updateTitle();
}
}
示例11: RebuildEditView
//.........这里部分代码省略.........
QLabel* label = new QLabel(QString::fromStdString(texname), mat_panel);
label->resize(200,20);
label->move(0, y*itemheight);
label->show();
}
// Attachments
ClearPanel(attachment_panel);
const AvatarAttachmentVector& attachments = appearance->GetAttachments();
attachment_panel->resize(width, itemheight * (attachments.size() + 1));
for (uint y = 0; y < attachments.size(); ++y)
{
QPushButton* button = new QPushButton("Remove", attachment_panel);
button->setObjectName(QString::fromStdString(ToString<int>(y))); // Attachment index
button->resize(50, 20);
button->move(width - 50, y*itemheight);
button->show();
QObject::connect(button, SIGNAL(clicked()), this, SLOT(RemoveAttachment()));
std::string attachment_name = attachments[y].name_;
// Strip away .xml from the attachment name for slightly nicer display
std::size_t pos = attachment_name.find(".xml");
if (pos != std::string::npos)
attachment_name = attachment_name.substr(0, pos);
QLabel* label = new QLabel(QString::fromStdString(attachment_name), attachment_panel);
label->resize(200,20);
label->move(0, y*itemheight);
label->show();
}
// Modifiers
QTabWidget* tabs = avatar_widget_->findChild<QTabWidget *>("tab_appearance");
if (!tabs)
return;
for (;;)
{
QWidget* tab = tabs->widget(0);
if (!tab)
break;
tabs->removeTab(0);
delete tab;
}
const MasterModifierVector& master_modifiers = appearance->GetMasterModifiers();
// If no master modifiers, show the individual morph/bone controls
if (!master_modifiers.size())
{
QWidget* morph_panel = GetOrCreateTabScrollArea(tabs, "Morphs");
QWidget* bone_panel = GetOrCreateTabScrollArea(tabs, "Bones");
if (!morph_panel || !bone_panel)
return;
const BoneModifierSetVector& bone_modifiers = appearance->GetBoneModifiers();
const MorphModifierVector& morph_modifiers = appearance->GetMorphModifiers();
morph_panel->resize(tab_width, itemheight * (morph_modifiers.size() + 1));
bone_panel->resize(tab_width, itemheight * (bone_modifiers.size() + 1));
for (uint i = 0; i < bone_modifiers.size(); ++i)
{
QScrollBar* slider = new QScrollBar(Qt::Horizontal, bone_panel);
slider->setObjectName(QString::fromStdString(bone_modifiers[i].name_));
slider->setMinimum(0);
slider->setMaximum(100);
slider->setPageStep(10);
slider->setValue(bone_modifiers[i].value_ * 100.0f);
slider->resize(150, 20);
slider->move(tab_width - 150, i * itemheight);
slider->show();
QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(BoneModifierValueChanged(int)));
QLabel* label = new QLabel(QString::fromStdString(bone_modifiers[i].name_), bone_panel);
label->resize(100,20);
label->move(0, i * itemheight);
label->show();
}
for (uint i = 0; i < morph_modifiers.size(); ++i)
{
QScrollBar* slider = new QScrollBar(Qt::Horizontal, morph_panel);
slider->setObjectName(QString::fromStdString(morph_modifiers[i].name_));
slider->setMinimum(0);
slider->setMaximum(100);
slider->setPageStep(10);
slider->setValue(morph_modifiers[i].value_ * 100.0f);
slider->resize(150, 20);
slider->move(tab_width - 150, i * itemheight);
slider->show();
QObject::connect(slider, SIGNAL(valueChanged(int)), this, SLOT(MorphModifierValueChanged(int)));
QLabel* label = new QLabel(QString::fromStdString(morph_modifiers[i].name_), morph_panel);
label->resize(100,20);
label->move(0, i * itemheight);
label->show();
}
}
示例12: paintEvent
void CtrlRegisterList::paintEvent(QPaintEvent *)
{
int numRowsTotal = cpu->GetNumRegsInCategory(category);
int maxRowsDisplay =rect().bottom()/rowHeight - 1;
selection = std::min(std::max(selection,0),numRowsTotal);
curVertOffset = std::max(std::min(curVertOffset,numRowsTotal - maxRowsDisplay),0);
QScrollBar *bar = findChild<QScrollBar*>("RegListScroll");
if(bar)
{
bar->setMinimum(0);
bar->setMaximum(numRowsTotal - maxRowsDisplay);
bar->setPageStep(1);
bar->setValue(curVertOffset);
}
QPainter painter(this);
painter.setBrush(Qt::white);
painter.setPen(Qt::white);
painter.drawRect(rect());
if (!cpu)
return;
QFont normalFont = QFont("Arial", 10);
painter.setFont(normalFont);
int width = rect().width();
QColor bgColor(0xffffff);
QPen nullPen(bgColor);
QPen currentPen(QColor(0xFF000000));
QPen selPen(0x808080);
QPen textPen;
QBrush lbr;
lbr.setColor(bgColor);
QBrush nullBrush(bgColor);
QBrush currentBrush(0xFFEfE8);
QBrush pcBrush(0x70FF70);
int nc = cpu->GetNumCategories();
for (int i=0; i<nc; i++)
{
painter.setPen(i==category?currentPen:nullPen);
painter.setBrush(i==category?pcBrush:nullBrush);
painter.drawRect(width*i/nc,0,width*(i+1)/nc - width*i/nc -1,rowHeight-1);
QString name = cpu->GetCategoryName(i);
painter.setPen(currentPen);
painter.drawText(width*i/nc+1,-3+rowHeight,name);
}
int numRows=rect().bottom()/rowHeight;
for (int i=curVertOffset; i<curVertOffset+numRows; i++)
{
int rowY1 = rowHeight*(i-curVertOffset+1);
int rowY2 = rowHeight*(i-curVertOffset+2)-1;
lbr.setColor(i==selection?0xffeee0:0xffffff);
painter.setBrush(currentBrush);
painter.setPen(nullPen);
painter.drawRect(0,rowY1,16-1,rowY2-rowY1);
if (selecting && i == selection)
painter.setPen(selPen);
else
painter.setPen(nullPen);
QBrush mojsBrush(lbr.color());
painter.setBrush(mojsBrush);
painter.drawRect(16,rowY1,width-16-1,rowY2-rowY1);
// Check for any changes in the registers.
if (lastPC != cpu->GetPC())
{
for (int i = 0, n = cpu->GetNumRegsInCategory(0); i < n; ++i)
{
u32 v = cpu->GetRegValue(0, i);
changedCat0Regs[i] = v != lastCat0Values[i];
lastCat0Values[i] = v;
}
lastPC = cpu->GetPC();
}
painter.setBrush(currentBrush);
if (i<cpu->GetNumRegsInCategory(category))
{
QString regName = cpu->GetRegName(category,i);
textPen.setColor(0x600000);
painter.setPen(textPen);
painter.drawText(17,rowY1-3+rowHeight,regName);
textPen.setColor(0xFF000000);
painter.setPen(textPen);
//.........这里部分代码省略.........