本文整理汇总了C++中QScrollArea::setVerticalScrollBar方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollArea::setVerticalScrollBar方法的具体用法?C++ QScrollArea::setVerticalScrollBar怎么用?C++ QScrollArea::setVerticalScrollBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollArea
的用法示例。
在下文中一共展示了QScrollArea::setVerticalScrollBar方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: setup
// Setup widget
void MyWidget::setup(int layoutMargin, QString borderColor, QString backgroundColor) {
// Some styling
visibleArea = QSize(600,400);
this->borderColor = borderColor;
this->backgroundColor = (backgroundColor == "" ? "rgba(0,0,0,200)" : backgroundColor);
borderLeftRight = -1;
borderTopDown = -1;
fullscreen = false;
// The different QRects
rectShown = QRect();
rectHidden = QRect(0,-10,10,10);
rectAni = QRect();
// The current geometry and position
isShown = false;
this->setGeometry(rectHidden);
// Fading
backOpacityShow = 0.5;
backOpacityCur = 0;
centerOpacityCur = 0;
fade = new QTimeLine;
fadeIN = true;
fadeEffectCenter = new QGraphicsOpacityEffect;
connect(fade, SIGNAL(valueChanged(qreal)), this, SLOT(fadeStep()));
connect(fade, SIGNAL(finished()), this, SLOT(aniFinished()));
// The current widget look
this->setStyleSheet(QString("background: rgba(0,0,0,%1);").arg(255*backOpacityShow));
// the central widget containing all the information
center = new QWidget(this);
center->setGraphicsEffect(fadeEffectCenter);
center->setObjectName("center");
// For some reason, if the border is not defined right here at the beginning, it wont be visible...
if(borderColor == "")
center->setStyleSheet(QString("#center { background: %1; border-radius: 10px; font-size: 12pt; }").arg(this->backgroundColor));
else
center->setStyleSheet(QString("#center {background: %1; border-radius: 15px; font-size: 12pt; border: 2px solid %2; }").arg(this->backgroundColor).arg(borderColor));
// Create and set the scrollarea with main layout
QVBoxLayout *central = new QVBoxLayout;
central->setMargin(layoutMargin);
QScrollArea *scroll = new QScrollArea(this);
scroll->setObjectName("scrollWidget");
scroll->setStyleSheet("QWidget#scrollWidget { background: transparent; padding-bottom: 3px; border-radius: 0px; }");
QWidget *scrollWidget = new QWidget(scroll->widget());
scrollWidget->setStyleSheet("background: transparent;");
scroll->setWidgetResizable(true);
scroll->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);
scrollWidget->setLayout(central);
scroll->setWidget(scrollWidget);
mainlayout = new QVBoxLayout;
if(layoutMargin == 0) mainlayout->setMargin(0);
center->setLayout(mainlayout);
mainlayout->addWidget(scroll);
// This widget gets the main layout set to
centralWidget = new QWidget;
central->addWidget(centralWidget);
// And set the custom scrollbar
scrollbar = new CustomScrollbar;
scroll->setVerticalScrollBar(scrollbar);
// And in case the monitor resolution is so small, that the horizontal scrollbar is visible:
CustomScrollbar *scrollbarHor = new CustomScrollbar;
scroll->setHorizontalScrollBar(scrollbarHor);
}
示例3: QWidget
SettingsTabOther::SettingsTabOther(QWidget *parent, QMap<QString, QVariant> set, bool v) : QWidget(parent) {
// The global settings
globSet = set;
verbose = v;
this->setObjectName("tabother");
this->setStyleSheet("#tabother { background: transparent; color: white; }");
tabs = new TabWidget;
tabs->expand(false);
tabs->setBorderTop("rgba(150,150,150,100)",2);
tabs->setBorderBot("rgba(150,150,150,100)",2);
QVBoxLayout *mainLay = new QVBoxLayout;
mainLay->addWidget(tabs);
this->setLayout(mainLay);
// the main scroll widget for all LOOK content
scrollbarOther = new CustomScrollbar;
QScrollArea *scrollOther = new QScrollArea;
QVBoxLayout *layOther = new QVBoxLayout(scrollOther);
QWidget *scrollWidgOther = new QWidget(scrollOther);
scrollWidgOther->setLayout(layOther);
scrollOther->setWidget(scrollWidgOther);
scrollOther->setWidgetResizable(true);
scrollOther->setVerticalScrollBar(scrollbarOther);
// the main scroll widget for all FEEL content
scrollbarFile = new CustomScrollbar;
QScrollArea *scrollFile = new QScrollArea;
QVBoxLayout *layFile = new QVBoxLayout(scrollFile);
QWidget *scrollWidgFile = new QWidget(scrollFile);
scrollWidgFile->setLayout(layFile);
scrollFile->setWidget(scrollWidgFile);
scrollFile->setWidgetResizable(true);
scrollFile->setVerticalScrollBar(scrollbarFile);
tabOther = new QWidget;
tabFile = new QWidget;
QVBoxLayout *scrollLayOther = new QVBoxLayout;
scrollLayOther->addWidget(scrollOther);
tabOther->setLayout(scrollLayOther);
QVBoxLayout *scrollLayFile = new QVBoxLayout;
scrollLayFile->addWidget(scrollFile);
tabFile->setLayout(scrollLayFile);
tabs->addTab(tabOther,tr("Other"));
tabs->addTab(tabFile,tr("File Types"));
// The titles
CustomLabel *titleOther = new CustomLabel("<center><h1>" + tr("Other Settings") + "</h1></center>");
layOther->addWidget(titleOther);
layOther->addSpacing(20);
CustomLabel *titleFile = new CustomLabel("<center><h1>" + tr("Known File Types") + "</h1></center>");
layFile->addWidget(titleFile);
layFile->addSpacing(20);
// CHOOSE A LANGUAGE
CustomLabel *langLabel = new CustomLabel("<b><span style=\"font-size:12pt\">" + tr("Choose Language") + "</span></b><br><br>" + tr("There are a good few different languages available. Thanks to everybody who took the time to translate PhotoQt!"));
langLabel->setWordWrap(true);
layOther->addWidget(langLabel);
layOther->addSpacing(15);
// All the languages available. They are sorted according to their language code (except English)
// A GOOD FEW OF THE TRANSLATIONS HAVEN'T BEEN UPDATED IN A LONG TIME AND ARE STANDING AT 0-5%
// These translations are NOT included!
langDesc << "English";
langShort << "en";
// Arabic
// langDesc << QString::fromUtf8("العربية (Amar T.)");
// langShort << "ar";
// Czech
langDesc << QString::fromUtf8("Čeština (Robin H. & Petr Š.)");
langShort << "cs";
// German
langDesc << "Deutsch";
langShort << "de";
// Greek
langDesc << QString::fromUtf8("Ελληνικά (Dimitrios G.)");
langShort << "el";
// Spanish
langDesc << QString::fromUtf8("Español (Hector C. & Victoria P.)");
langShort << "es_ES";
// Finnish
//.........这里部分代码省略.........
示例4: QWidget
SettingsTabThumbnail::SettingsTabThumbnail(QWidget *parent, QMap<QString, QVariant> set, bool v) : QWidget(parent) {
// The global settings
globSet = set;
this->setObjectName("tabthumb");
verbose = v;
// Opening the thumbnail database
db = QSqlDatabase::database("thumbDB");
// Style the widget
this->setStyleSheet("#tabthumb { background: transparent; color: white; }");
tabs = new TabWidget;
tabs->expand(false);
tabs->setBorderTop("rgba(150,150,150,100)",2);
tabs->setBorderBot("rgba(150,150,150,100)",2);
QVBoxLayout *mainLay = new QVBoxLayout;
mainLay->addWidget(tabs);
this->setLayout(mainLay);
// the main scroll widget for all LOOK content
scrollbarLook = new CustomScrollbar;
QScrollArea *scrollLook = new QScrollArea;
QVBoxLayout *layLook = new QVBoxLayout(scrollLook);
QWidget *scrollWidgLook = new QWidget(scrollLook);
scrollWidgLook->setLayout(layLook);
scrollLook->setWidget(scrollWidgLook);
scrollLook->setWidgetResizable(true);
scrollLook->setVerticalScrollBar(scrollbarLook);
// the main scroll widget for all FEEL content
scrollbarTune = new CustomScrollbar;
QScrollArea *scrollTune = new QScrollArea;
QVBoxLayout *layTune = new QVBoxLayout(scrollTune);
QWidget *scrollWidgTune = new QWidget(scrollTune);
scrollWidgTune->setLayout(layTune);
scrollTune->setWidget(scrollWidgTune);
scrollTune->setWidgetResizable(true);
scrollTune->setVerticalScrollBar(scrollbarTune);
tabLook = new QWidget;
tabTune = new QWidget;
QVBoxLayout *scrollLayLook = new QVBoxLayout;
scrollLayLook->addWidget(scrollLook);
tabLook->setLayout(scrollLayLook);
QVBoxLayout *scrollLayTune = new QVBoxLayout;
scrollLayTune->addWidget(scrollTune);
tabTune->setLayout(scrollLayTune);
tabs->addTab(tabLook,tr("Look"));
tabs->addTab(tabTune,tr("Fine-Tuning"));
// The titles
CustomLabel *titleLook = new CustomLabel("<center><h1>" + tr("Thumbnail Look") + "</h1></center>");
layLook->addWidget(titleLook);
layLook->addSpacing(20);
CustomLabel *titleTune = new CustomLabel("<center><h1>" + tr("Fine-Tuning of Thumbnails") + "</h1></center>");
layTune->addWidget(titleTune);
layTune->addSpacing(20);
// OPTION TO CHANGE THUMBNAIL SIZE
CustomLabel *thumbSizeLabel = new CustomLabel("<b><span style=\"font-size: 12pt\">" + tr("Thumbnail Size") + "</span></b><br><br>" + tr("Here you can adjust the thumbnail size. You can set it to any size between 20 and 256 pixel. Per default it is set to 80 pixel, but with different screen resolutions it might be nice to have them larger/smaller."));
thumbSizeLabel->setWordWrap(true);
QHBoxLayout *thumbSizeLay = new QHBoxLayout;
thumbSizeSlider = new CustomSlider;
thumbSizeSlider->setMinimum(20);
thumbSizeSlider->setMaximum(256);
thumbSizeSpin = new CustomSpinBox;
thumbSizeSpin->setMinimum(20);
thumbSizeSpin->setMaximum(256);
thumbSizeLay->addStretch();
thumbSizeLay->addWidget(thumbSizeSlider);
thumbSizeLay->addWidget(thumbSizeSpin);
thumbSizeLay->addStretch();
layLook->addWidget(thumbSizeLabel);
layLook->addSpacing(5);
layLook->addLayout(thumbSizeLay);
layLook->addSpacing(20);
connect(thumbSizeSlider, SIGNAL(valueChanged(int)), thumbSizeSpin, SLOT(setValue(int)));
connect(thumbSizeSpin, SIGNAL(valueChanged(int)), thumbSizeSlider, SLOT(setValue(int)));
// OPTION TO SET SPACING BETWEEN THUMBNAILS
borderAroundSlider = new CustomSlider;
borderAroundSlider->setMinimum(0);
borderAroundSlider->setMaximum(30);
borderAroundSlider->setTickInterval(4);
borderAroundSpin = new CustomSpinBox;
borderAroundSpin->setMinimum(0);
//.........这里部分代码省略.........