本文整理汇总了C++中QScrollArea::horizontalScrollBar方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::horizontalScrollBar方法的具体用法?C++ QScrollArea::horizontalScrollBar怎么用?C++ QScrollArea::horizontalScrollBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::horizontalScrollBar方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void Cocos2dxView::mouseMoveInBrowse(QMouseEvent *event)
{
qDebug("move browse");
QPointF curPos = event->localPos();
QPointF diff = curPos - m_prePosition;
qDebug("diff: %f %f", diff.x(), diff.y());
QScrollArea *scroll = (QScrollArea*)this->parent()->parent();
scroll->horizontalScrollBar()->setValue(scroll->horizontalScrollBar()->value() - diff.x());
scroll->verticalScrollBar()->setValue(scroll->verticalScrollBar()->value() - diff.y());
m_prePosition = curPos;
}
示例2: QMdiSubWindow
/*!
\brief Constructor.
Creates a new instance of ProjectWindow.
\param pro project data to show, not null.
\param parent parent widgets of this window, default value is 0.
*/
Ui::ProjectWindow::ProjectWindow(Core::Project *pro, QWidget *parent /* = 0 */)
: QMdiSubWindow(parent),
project(pro)
{
// entry conditions
Q_CHECK_PTR(pro);
setAttribute(Qt::WA_DeleteOnClose);
setWindowIcon(QIcon(":/proj"));
setWindowTitle(project->name());
setMinimumSize(200, 200);
// project view, the main widget
view = new ProjectView(this);
scene = new ProjectScene(project, this);
view->setScene(scene);
view->setSceneRect(0, 0, project->width(), project->height());
QScrollArea* centerPanel = new QScrollArea(this);
centerPanel->viewport()->setStyleSheet(QString("background-color:#C0C0C0"));
centerPanel->setAlignment(Qt::AlignCenter);
centerPanel->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
centerPanel->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
centerPanel->setWidget(view);
// status bar
statusBar = new QWidget(this);
QHBoxLayout *statusLayout = new QHBoxLayout(statusBar);
statusLayout->setMargin(0);
statusBar->setLayout(statusLayout);
QLineEdit* percentInput = new QLineEdit(statusBar);
percentInput->setText("100");
percentInput->setFixedSize(40, 18);
QLabel *msgLabel = new QLabel(statusBar);
msgLabel->setText("%");
msgLabel->setFixedWidth(8);
QPushButton *gridButton = new QPushButton(statusBar);
gridButton->setText("#");
gridButton->setCheckable(true);
gridButton->setFixedSize(20, 18);
QLabel *ctrlLabel = new QLabel(statusBar);
ctrlLabel->setFixedWidth(qApp->style()->pixelMetric(QStyle::PM_ScrollBarExtent) - 6);
statusLayout->addWidget(percentInput);
statusLayout->addWidget(msgLabel);
statusLayout->addWidget(gridButton);
statusLayout->addWidget(centerPanel->horizontalScrollBar(), 100);
statusLayout->addWidget(ctrlLabel);
QWidget *mainPanel = new QWidget(this);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->setMargin(0);
mainLayout->setSpacing(0);
mainLayout->addWidget(centerPanel);
mainLayout->addWidget(statusBar);
mainPanel->setLayout(mainLayout);
setWidget(mainPanel);
connect(gridButton, SIGNAL(clicked(bool)), scene, SLOT(showGrid(bool)));
connect(appCtx->mainWindow(), SIGNAL(antialiasingChanged(bool)), scene, SLOT(setAntialiasing(bool)));
}
示例3: resizeEvent
void PatternEditorPanel::resizeEvent( QResizeEvent *ev )
{
UNUSED( ev );
QScrollArea *pScrollArea = m_pEditorScrollView;
pScrollArea = m_pEditorScrollView;
m_pPatternEditorHScrollBar->setMinimum( pScrollArea->horizontalScrollBar()->minimum() );
m_pPatternEditorHScrollBar->setMaximum( pScrollArea->horizontalScrollBar()->maximum() );
m_pPatternEditorHScrollBar->setSingleStep( pScrollArea->horizontalScrollBar()->singleStep() );
m_pPatternEditorHScrollBar->setPageStep( pScrollArea->horizontalScrollBar()->pageStep() );
m_pPatternEditorVScrollBar->setMinimum( pScrollArea->verticalScrollBar()->minimum() );
m_pPatternEditorVScrollBar->setMaximum( pScrollArea->verticalScrollBar()->maximum() );
m_pPatternEditorVScrollBar->setSingleStep( pScrollArea->verticalScrollBar()->singleStep() );
m_pPatternEditorVScrollBar->setPageStep( pScrollArea->verticalScrollBar()->pageStep() );
}
示例4: eventFilter
bool MainWindow::eventFilter( QObject * object, QEvent * event )
{
QScrollArea * scrollArea = ui->scrollArea;
if ( object == scrollArea )
{
if ( event->type() == QEvent::MouseButtonPress )
{
QMouseEvent * mouseEvent = static_cast < QMouseEvent * > ( event );
if ( mouseEvent->button() == Qt::LeftButton )
{
lastPos = mouseEvent->pos();
if( scrollArea->horizontalScrollBar()->isVisible() || scrollArea->verticalScrollBar()->isVisible() )
scrollArea->setCursor( Qt::ClosedHandCursor );
else
scrollArea->setCursor( Qt::ArrowCursor );
}
}else if ( event->type() == QEvent::MouseMove )
{
QMouseEvent *mouseEvent = static_cast < QMouseEvent * > ( event );
if ( mouseEvent->buttons() == Qt::LeftButton )
{
lastPos -= mouseEvent->pos();
int hValue = scrollArea->horizontalScrollBar()->value();
int vValue = scrollArea->verticalScrollBar()->value();
scrollArea->horizontalScrollBar()->setValue( lastPos.x() + hValue );
scrollArea->verticalScrollBar()->setValue( lastPos.y() + vValue );
lastPos = mouseEvent->pos();
}
}else if ( event->type() == QEvent::MouseButtonRelease )
scrollArea->setCursor( Qt::ArrowCursor );
}
return QWidget::eventFilter(object, event);
}
示例5: playing
void
WPiano::look_at_cursor(LookMode mode)
{
QWidget *viewport_widget = qobject_cast<QWidget *>(parent());
if (viewport_widget == NULL)
return;
QScrollArea *scroll = qobject_cast<QScrollArea *>(viewport_widget->parent());
if (scroll == NULL)
return;
QScrollBar *hs = scroll->horizontalScrollBar();
QScrollBar *vs = scroll->verticalScrollBar();
bool pl = playing();
QRect v = viewport();
int x1, x2, y1, y2;
x1 = time2x(cursorTime());
x2 = pl ? x1 + 1 : time2x(cursorEndTime());
y1 = level2y(cursor_level_ + 1);
y2 = level2y(cursor_level_ - 1);
switch (mode) {
case PAGE:
if (x1 < v.left())
hs->setValue(scroll_snap(this, x2 - v.width(), true));
if (x2 > v.right())
hs->setValue(scroll_snap(this, x1 - 1));
if (pl && y1 < v.top())
vs->setValue(y2 - v.height() + level_height);
if (pl && y2 > v.bottom())
vs->setValue(y1 - level_height);
break;
case MINSCROLL:
scroll->ensureVisible(x1, y1, level_height, level_height);
scroll->ensureVisible(x2, y2, level_height, level_height);
break;
case CENTER:
hs->setValue((x1 + x2 - v.width()) / 2);
vs->setValue((y1 + y2 - v.height()) / 2);
break;
}
}
示例6: QFETCH
void tst_QAbstractScrollArea::task214488_layoutDirection()
{
QScrollArea scrollArea;
scrollArea.resize(200, 200);
QWidget widget;
widget.resize(600, 600);
scrollArea.setWidget(&widget);
scrollArea.show();
QScrollBar *hbar = scrollArea.horizontalScrollBar();
hbar->setValue((hbar->minimum() + hbar->maximum()) / 2);
QFETCH(Qt::LayoutDirection, dir);
QFETCH(Qt::Key, key);
QFETCH(bool, lessThan);
scrollArea.setLayoutDirection(dir);
int refValue = hbar->value();
qApp->sendEvent(&scrollArea, new QKeyEvent(QEvent::KeyPress, key, Qt::NoModifier));
QVERIFY(lessThan ? (hbar->value() < refValue) : (hbar->value() > refValue));
}
示例7: mouseMoveEvent
/** Called when the mouse is being moved */
void CMapWidget::mouseMoveEvent(QMouseEvent *e)
{
if (bMouseDrag)
{
int dx, dy;
dx = e->globalX() - nMouseDragPosX;
dy = e->globalY() - nMouseDragPosY;
nMouseDragPosX = e->globalX();
nMouseDragPosY = e->globalY();
QScrollArea *parent = (QScrollArea *) parentWidget();
QScrollBar *sx = parent->horizontalScrollBar();
QScrollBar *sy = parent->verticalScrollBar();
sx->setValue(sx->value() + dx*3);
sy->setValue(sy->value() + dy*3);
}
else
{
// Send the mouse event to the current tool
mapManager->getCurrentTool()->mouseMoveEvent(e->pos(),e->button(),viewWidget->getCurrentlyViewedLevel());
}
}
示例8: QWidget
CPUWidget::CPUWidget(QWidget* parent) : QWidget(parent), ui(new Ui::CPUWidget)
{
ui->setupUi(this);
setDefaultDisposition();
mDisas = new CPUDisassembly(0);
mSideBar = new CPUSideBar(mDisas);
connect(mDisas, SIGNAL(tableOffsetChanged(int_t)), mSideBar, SLOT(changeTopmostAddress(int_t)));
connect(mDisas, SIGNAL(viewableRows(int)), mSideBar, SLOT(setViewableRows(int)));
connect(mDisas, SIGNAL(repainted()), mSideBar, SLOT(repaint()));
connect(mDisas, SIGNAL(selectionChanged(int_t)), mSideBar, SLOT(setSelection(int_t)));
connect(Bridge::getBridge(), SIGNAL(dbgStateChanged(DBGSTATE)), mSideBar, SLOT(debugStateChangedSlot(DBGSTATE)));
connect(Bridge::getBridge(), SIGNAL(updateSideBar()), mSideBar, SLOT(repaint()));
QSplitter* splitter = new QSplitter(this);
splitter->addWidget(mSideBar);
splitter->addWidget(mDisas);
splitter->setChildrenCollapsible(false);
splitter->setHandleWidth(1);
ui->mTopLeftUpperFrameLayout->addWidget(splitter);
mInfo = new CPUInfoBox();
ui->mTopLeftLowerFrameLayout->addWidget(mInfo);
int height = mInfo->getHeight();
ui->mTopLeftLowerFrame->setMinimumHeight(height + 2);
ui->mTopLeftLowerFrame->setMaximumHeight(height + 2);
connect(mDisas, SIGNAL(selectionChanged(int_t)), mInfo, SLOT(disasmSelectionChanged(int_t)));
mGeneralRegs = new RegistersView(0);
mGeneralRegs->setFixedWidth(1000);
mGeneralRegs->setFixedHeight(1400);
mGeneralRegs->ShowFPU(true);
QScrollArea* scrollArea = new QScrollArea;
scrollArea->setWidget(mGeneralRegs);
scrollArea->horizontalScrollBar()->setStyleSheet("QScrollBar:horizontal{border:1px solid grey;background:#f1f1f1;height:10px}QScrollBar::handle:horizontal{background:#aaa;min-width:20px;margin:1px}QScrollBar::add-line:horizontal,QScrollBar::sub-line:horizontal{width:0;height:0}");
scrollArea->verticalScrollBar()->setStyleSheet("QScrollBar:vertical{border:1px solid grey;background:#f1f1f1;width:10px}QScrollBar::handle:vertical{background:#aaa;min-height:20px;margin:1px}QScrollBar::add-line:vertical,QScrollBar::sub-line:vertical{width:0;height:0}");
QPushButton* button_changeview = new QPushButton("");
mGeneralRegs->SetChangeButton(button_changeview);
button_changeview->setStyleSheet("Text-align:left;padding: 4px;padding-left: 10px;");
QFont font = QFont("Lucida Console");
font.setStyleHint(QFont::Monospace);
font.setPointSize(8);
button_changeview->setFont(font);
connect(button_changeview, SIGNAL(clicked()), mGeneralRegs, SLOT(onChangeFPUViewAction()));
ui->mTopRightFrameLayout->addWidget(button_changeview);
ui->mTopRightFrameLayout->addWidget(scrollArea);
mDump = new CPUDump(mDisas, 0); //dump widget
ui->mBotLeftFrameLayout->addWidget(mDump);
mStack = new CPUStack(0); //stack widget
ui->mBotRightFrameLayout->addWidget(mStack);
}
示例9: setScrollBars
void tst_QAbstractScrollArea::setScrollBars()
{
QScrollArea scrollArea;
scrollArea.resize(300, 300);
scrollArea.show();
QPointer<QScrollBar> vbar = scrollArea.verticalScrollBar();
QPointer<QScrollBar> hbar = scrollArea.horizontalScrollBar();
// Now set properties on the scroll bars
scrollArea.verticalScrollBar()->setInvertedAppearance(true);
scrollArea.verticalScrollBar()->setInvertedControls(true);
scrollArea.verticalScrollBar()->setTracking(true);
scrollArea.verticalScrollBar()->setRange(-100, 100);
scrollArea.verticalScrollBar()->setPageStep(42);
scrollArea.verticalScrollBar()->setSingleStep(3);
scrollArea.verticalScrollBar()->setValue(43);
scrollArea.horizontalScrollBar()->setInvertedAppearance(true);
scrollArea.horizontalScrollBar()->setInvertedControls(true);
scrollArea.horizontalScrollBar()->setTracking(true);
scrollArea.horizontalScrollBar()->setRange(-100, 100);
scrollArea.horizontalScrollBar()->setPageStep(42);
scrollArea.horizontalScrollBar()->setSingleStep(3);
scrollArea.horizontalScrollBar()->setValue(43);
qApp->processEvents();
// Then replace the scroll bars
scrollArea.setVerticalScrollBar(new QScrollBar);
scrollArea.setHorizontalScrollBar(new QScrollBar);
// Check that the old ones were deleted
QVERIFY(!vbar);
QVERIFY(!hbar);
qApp->processEvents();
// Check that all properties have been populated
QVERIFY(scrollArea.verticalScrollBar()->invertedAppearance());
QVERIFY(scrollArea.verticalScrollBar()->invertedControls());
QVERIFY(scrollArea.verticalScrollBar()->hasTracking());
QVERIFY(scrollArea.verticalScrollBar()->isVisible());
QCOMPARE(scrollArea.verticalScrollBar()->minimum(), -100);
QCOMPARE(scrollArea.verticalScrollBar()->maximum(), 100);
QCOMPARE(scrollArea.verticalScrollBar()->pageStep(), 42);
QCOMPARE(scrollArea.verticalScrollBar()->singleStep(), 3);
QCOMPARE(scrollArea.verticalScrollBar()->value(), 43);
QVERIFY(scrollArea.horizontalScrollBar()->invertedAppearance());
QVERIFY(scrollArea.horizontalScrollBar()->invertedControls());
QVERIFY(scrollArea.horizontalScrollBar()->hasTracking());
QVERIFY(scrollArea.horizontalScrollBar()->isVisible());
QCOMPARE(scrollArea.horizontalScrollBar()->minimum(), -100);
QCOMPARE(scrollArea.horizontalScrollBar()->maximum(), 100);
QCOMPARE(scrollArea.horizontalScrollBar()->pageStep(), 42);
QCOMPARE(scrollArea.horizontalScrollBar()->singleStep(), 3);
QCOMPARE(scrollArea.horizontalScrollBar()->value(), 43);
}