本文整理汇总了C++中QScrollBar类的典型用法代码示例。如果您正苦于以下问题:C++ QScrollBar类的具体用法?C++ QScrollBar怎么用?C++ QScrollBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QScrollBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
//.........这里部分代码省略.........
m_edtWater->setDecimalVisible( false );
m_edtWater->setPmVisible( false );
m_edtWater->setMaxLength(4);
m_edtWater->setSuffix(" l");
m_edtWater->setRange( 0, 9999 );
m_edtWater->setValue( 0 );
topLayout->addWidget(m_edtWater, row, 3);
row++;
QHBoxLayout* hbox = new QHBoxLayout;
hbox->addWidget( new QLabel(tr("Ref. weight:"), this) );
m_refWeight = new QLabel;
m_refWeight->setFocusPolicy(Qt::NoFocus);
hbox->addWidget( m_refWeight, 10 );
topLayout->addLayout( hbox, row, 0, 1, 2 );
hbox = new QHBoxLayout;
hbox->addWidget( new QLabel(tr("Wing load:"), this) );
m_wingLoad = new QLabel;
m_wingLoad->setFocusPolicy(Qt::NoFocus);
hbox->addWidget( m_wingLoad, 10 );
topLayout->addLayout( hbox, row, 2, 1, 2 );
row++;
topLayout->setRowMinimumHeight( row, 10 );
row++;
m_gliderList = new GliderListWidget( this, true );
#ifndef ANDROID
m_gliderList->setToolTip(tr("Select a glider to be used"));
#endif
#ifdef ANDROID
QScrollBar* lvsb = m_gliderList->verticalScrollBar();
lvsb->setStyleSheet( Layout::getCbSbStyle() );
#endif
#ifdef QSCROLLER
QScroller::grabGesture(m_gliderList->viewport(), QScroller::LeftMouseButtonGesture);
#endif
#ifdef QTSCROLLER
QtScroller::grabGesture(m_gliderList->viewport(), QtScroller::LeftMouseButtonGesture);
#endif
topLayout->addWidget(m_gliderList, row, 0, 1, 4);
row++;
//---------------------------------------------------------------------
QPushButton* deselect = new QPushButton( tr("Deselect"), this );
#ifndef ANDROID
deselect->setToolTip( tr("Clear glider selection") );
#endif
topLayout->addWidget( deselect, row, 3 );
//---------------------------------------------------------------------
m_gliderList->fillList();
m_gliderList->clearSelection();
m_gliderList->selectItemFromList();
connect(deselect, SIGNAL(clicked()), this, SLOT(slotGliderDeselected()) );
connect(m_gliderList, SIGNAL(itemSelectionChanged()), this, SLOT(slotGliderChanged()));
connect(m_edtLoad, SIGNAL(numberEdited(const QString&)), this, SLOT(slotLoadEdited(const QString&)));
connect(m_edtWater, SIGNAL(numberEdited(const QString&)), this, SLOT(slotWaterEdited(const QString&)));
QPushButton *help = new QPushButton(this);
help->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("help32.png")));
help->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12)));
help->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);
QPushButton *cancel = new QPushButton(this);
cancel->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("cancel.png")));
cancel->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12)));
cancel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);
QPushButton *ok = new QPushButton(this);
ok->setIcon(QIcon(GeneralConfig::instance()->loadPixmap("ok.png")));
ok->setIconSize(QSize(Layout::getButtonSize(12), Layout::getButtonSize(12)));
ok->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::QSizePolicy::Preferred);
QLabel *titlePix = new QLabel(this);
titlePix->setAlignment( Qt::AlignCenter );
titlePix->setPixmap( _globalMapConfig->createGlider(315, 1.6) );
connect(help, SIGNAL(pressed()), this, SLOT(slotHelp()));
connect(ok, SIGNAL(pressed()), this, SLOT(slotAccept()));
connect(cancel, SIGNAL(pressed()), this, SLOT(slotReject()));
QVBoxLayout *buttonBox = new QVBoxLayout;
buttonBox->setSpacing(0);
buttonBox->addWidget(help, 1);
buttonBox->addStretch(2);
buttonBox->addWidget(cancel, 1);
buttonBox->addSpacing(30);
buttonBox->addWidget(ok, 1);
buttonBox->addStretch(2);
buttonBox->addWidget(titlePix);
contentLayout->addLayout(buttonBox);
}
示例2: QCheckBox
//.........这里部分代码省略.........
}
else if(name == "ProgressBar")
{
QProgressBar* bar = new QProgressBar;
bar->setObjectName("ProgressBar");
bar->setRange(0, 100);
bar->setValue(0);
QTimer* timer = new QTimer(bar);
this->connect(timer, &QTimer::timeout, this, [bar]()
{
if(bar->value() == 100)
bar->setValue(0);
else
bar->setValue(bar->value() + 1);
});
timer->start(100);
return setLayoutWidget({ bar }, { 110, 30 });
}
else if(name == "PushButton")
{
QPushButton* button = new QPushButton("PushButton");
button->setObjectName("PushButton");
return setLayoutWidget({ button }, { 125, 30 });
}
else if(name == "RadioButton")
{
QRadioButton* button = new QRadioButton("RadioButton");
button->setObjectName("RadioButton");
return setLayoutWidget({ button }, { 125, 30 });
}
else if(name == "ScrollBar")
{
QScrollBar* barH = new QScrollBar(Qt::Horizontal);
QScrollBar* barV = new QScrollBar(Qt::Vertical);
barH->setObjectName("ScrollBarH");
barV->setObjectName("ScrollBarV");
return setLayoutWidget({ barH, barV }, { 200, 100 });
}
else if(name == "Slider")
{
QSlider* sliderH = new QSlider(Qt::Horizontal);
QSlider* sliderV = new QSlider(Qt::Vertical);
sliderH->setObjectName("SliderH");
sliderV->setObjectName("SliderV");
return setLayoutWidget({ sliderH, sliderV }, { 200, 100 });
}
else if(name == "SpinBox")
{
QSpinBox* spinBox = new QSpinBox;
spinBox->setObjectName("SpinBox");
return setLayoutWidget({ spinBox }, { 60, 35 });
}
else if(name == "Splitter")
{
QSplitter* splitterV = new QSplitter(Qt::Vertical);
QSplitter* splitterH = new QSplitter(Qt::Horizontal);
splitterV->setObjectName("SplitterV");
splitterH->setObjectName("SplitterH");
splitterV->addWidget(new QPushButton("PushButton1"));
splitterV->addWidget(new QPushButton("PushButton2"));
splitterH->addWidget(splitterV);
splitterH->addWidget(new QPushButton("PushButton3"));
return setLayoutWidget({ splitterH }, { 250, 110 });
}
else if(name == "TabWidget")
示例3: verticalScrollBar
void ChatAreaWidget::onSliderRangeChanged()
{
QScrollBar* scroll = verticalScrollBar();
if (lockSliderToBottom)
scroll->setValue(scroll->maximum());
}
示例4: QColor
/**
* Adds a log entry
*/
void LogWidget::log(LogType logType, QString text) {
#ifndef INTEGRATION_TESTS
// return if logging wasn't enabled
if (!qApp->property("loggingEnabled").toBool()) {
return;
}
QString type = "";
QColor color = QColor(Qt::black);
switch (logType) {
case DebugLogType:
if (!ui->debugCheckBox->isChecked()) {
return;
}
type = "debug";
// gray
color = QColor(98, 98, 98);
break;
case InfoLogType:
if (!ui->infoCheckBox->isChecked()) {
return;
}
type = "info";
color = QColor(Qt::darkBlue);
break;
case WarningLogType:
if (!ui->warningCheckBox->isChecked()) {
return;
}
type = "warning";
// orange
color = QColor(255, 128, 0);
break;
case CriticalLogType:
if (!ui->criticalCheckBox->isChecked()) {
return;
}
type = "critical";
// light red
color = QColor(192, 0, 0);
break;
case FatalLogType:
if (!ui->fatalCheckBox->isChecked()) {
return;
}
type = "fatal";
// lighter red
color = QColor(210, 0, 0);
break;
case StatusLogType:
if (!ui->statusCheckBox->isChecked()) {
return;
}
type = "status";
// green
color = QColor(0, 128, 0);
break;
case ScriptingLogType:
if (!ui->scriptingCheckBox->isChecked()) {
return;
}
type = "scripting";
// blue
color = QColor(0, 102, 255);
break;
default:
type = "unknown";
break;
}
QDateTime dateTime = QDateTime::currentDateTime();
// text.prepend("[" + dateTime.toString("hh:mm:ss") + "] [" + type + "] ");
// text.append("\n");
QString html = QString("<div style=\"color: %1\">[%2] [%3] %4</div><br />")
.arg(color.name(), dateTime.toString("hh:mm:ss"), type,
text.toHtmlEscaped());
QScrollBar *scrollBar = ui->logTextEdit->verticalScrollBar();
// we want to scroll down later if the scrollbar is near the end bottom
bool scrollDown = scrollBar->value() >=
(scrollBar->maximum() - scrollBar->singleStep());
QTextCursor c = ui->logTextEdit->textCursor();
// insert the text at the end
c.movePosition(QTextCursor::End);
c.insertHtml(html);
if (scrollDown) {
// move the text cursor to the end
ui->logTextEdit->moveCursor(QTextCursor::End);
}
#else
Q_UNUSED(logType);
//.........这里部分代码省略.........
示例5: verticalScrollBar
void Console::scrollDown()
{
QScrollBar *vbar = verticalScrollBar();
vbar->setValue(vbar->maximum());
}
示例6: 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);
}
示例7: printf
void TrackListView::populateTable()/*{{{*/
{
if(debugMsg)
printf("TrackListView::populateTable\n");
QScrollBar *bar = m_table->verticalScrollBar();
int barPos = 0;
if(bar)
barPos = bar->sliderPosition();
m_model->clear();
for(iMidiTrack i = song->artracks()->begin(); i != song->artracks()->end(); ++i)
{
MidiTrack* track = (MidiTrack*)(*i);
PartList* pl = track->parts();
if(m_displayRole == PartRole && pl->empty())
{
continue;
}
QStandardItem* trackName = new QStandardItem();
trackName->setForeground(QBrush(QColor(205,209,205)));
trackName->setBackground(QBrush(QColor(20,20,20)));
trackName->setFont(QFont("fixed-width", 10, QFont::Bold));
trackName->setText(track->name());
trackName->setCheckable(true);
trackName->setCheckState(m_selectedTracks.contains(track->id()) ? Qt::Checked : Qt::Unchecked);
trackName->setTextAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
trackName->setData(1, TrackRole);
trackName->setData(track->name(), TrackNameRole);
trackName->setData(track->id(), TrackIdRole);
trackName->setEditable(true);
m_model->appendRow(trackName);
for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
{
Part* part = ip->second;
QStandardItem* partName = new QStandardItem();
partName->setFont(QFont("fixed-width", 9, QFont::Bold));
partName->setText(part->name());
partName->setData(part->sn(), PartRole);
partName->setData(2, TrackRole);
partName->setData(track->name(), TrackNameRole);
partName->setData(part->name(), PartNameRole);
partName->setData(part->tick(), TickRole);
partName->setData(track->id(), TrackIdRole);
partName->setEditable(true);
partName->setCheckable(true);
partName->setCheckState(m_editor->hasPart(part->sn()) ? Qt::Checked : Qt::Unchecked);
if(!partColorIcons.isEmpty() && part->colorIndex() < partColorIcons.size())
partName->setIcon(partColorIcons.at(part->colorIndex()));
m_model->appendRow(partName);
}
}
m_model->setHorizontalHeaderLabels(m_headers);
if(m_selectedIndex < m_model->rowCount())
{
m_table->selectRow(m_selectedIndex);
m_table->scrollTo(m_model->index(m_selectedIndex, 0));
}
if(bar)
bar->setSliderPosition(barPos);
}/*}}}*/
示例8: onSliderRangeChanged
void GroupChatForm::onSliderRangeChanged()
{
QScrollBar* scroll = chatArea->verticalScrollBar();
if (lockSliderToBottom)
scroll->setValue(scroll->maximum());
}
示例9: 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);
//.........这里部分代码省略.........
示例10: gestureEvent
void gestureEvent(QGestureEvent *event)
{
QPanGesture *pan = static_cast<QPanGesture *>(event->gesture(Qt::PanGesture));
if (pan) {
switch(pan->state()) {
case Qt::GestureStarted: qDebug() << this << "Pan: started"; break;
case Qt::GestureFinished: qDebug() << this << "Pan: finished"; break;
case Qt::GestureCanceled: qDebug() << this << "Pan: canceled"; break;
case Qt::GestureUpdated: break;
default: qDebug() << this << "Pan: <unknown state>"; break;
}
if (pan->state() == Qt::GestureStarted)
outside = false;
event->ignore();
event->ignore(pan);
if (outside)
return;
const QPointF delta = pan->delta();
const QPointF totalOffset = pan->offset();
QScrollBar *vbar = verticalScrollBar();
QScrollBar *hbar = horizontalScrollBar();
if ((vbar->value() == vbar->minimum() && totalOffset.y() > 10) ||
(vbar->value() == vbar->maximum() && totalOffset.y() < -10)) {
outside = true;
return;
}
if ((hbar->value() == hbar->minimum() && totalOffset.x() > 10) ||
(hbar->value() == hbar->maximum() && totalOffset.x() < -10)) {
outside = true;
return;
}
vbar->setValue(vbar->value() - delta.y());
hbar->setValue(hbar->value() - delta.x());
event->accept(pan);
}
}
示例11: scrollToBottom
void LogViewForm::scrollToBottom()
{
QScrollBar* vsb = logTextEdit->verticalScrollBar();
vsb->setValue(vsb->maximum());
logTextEdit->update();
}
示例12: ScrollChanged
void ScriptLogWindow::ScrollChanged(int val)
{
QScrollBar *scroll = scriptLogWidget->verticalScrollBar();
bottomScrolled = (val == scroll->maximum());
}
示例13:
void KTreeView::KTreeViewPrivate::updateVerticalScrollBar(int value)
{
QScrollBar *scrollBar = parent->horizontalScrollBar();
scrollBar->setValue(value);
}
示例14: if
void Serveur::ecrire(QString txt,QString destChan,QString msgTray)
{
if(destChan.toStdString() == "Console/PM")
{
affichage->setHtml(affichage->toHtml()+txt);
QScrollBar *sb = affichage->verticalScrollBar();
sb->setValue(sb->maximum());
}
else if(destChan!="")
{
conversations[destChan]->setHtml(conversations[destChan]->toHtml()+txt);
QScrollBar *sb = conversations[destChan]->verticalScrollBar();
sb->setValue(sb->maximum());
}
else if(txt.startsWith("#"))
{
QString dest=txt.split(" ").first();
QStringList list=txt.split(" ");
list.removeFirst();
txt=list.join(" ");
conversations[dest]->setHtml(conversations[dest]->toHtml()+txt);
QScrollBar *sb = conversations[dest]->verticalScrollBar();
sb->setValue(sb->maximum());
}
else
{
affichage->setHtml(affichage->toHtml()+txt);
QScrollBar *sb = affichage->verticalScrollBar();
sb->setValue(sb->maximum());
}
}
示例15: setDiffView
void DiffZoomWidget::setDiffView(DiffView *view)
{
diffview = view;
QScrollBar *sb = const_cast<QScrollBar*>(diffview->scrollBar());
sb->installEventFilter(this);
}