本文整理汇总了C++中QScrollBar::setEnabled方法的典型用法代码示例。如果您正苦于以下问题:C++ QScrollBar::setEnabled方法的具体用法?C++ QScrollBar::setEnabled怎么用?C++ QScrollBar::setEnabled使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QScrollBar
的用法示例。
在下文中一共展示了QScrollBar::setEnabled方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: refreshLayout
void ThumbnailStrip::refreshLayout()
{
QRect avail = geometry();
avail.adjust(6, 6, -6, -6);
int numActive = 0;
for(ResourcePreview *c : m_Thumbnails)
if(c->isActive())
numActive++;
// depending on overall aspect ratio, we either lay out the strip horizontally or
// vertically. This tries to account for whether the strip is docked along one side
// or another of the texture viewer
if(avail.width() > avail.height())
{
avail.setWidth(avail.width() + 6); // controls implicitly have a 6 margin on the right
int aspectWidth = (int)((float)avail.height() * 1.3f);
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
delete layout;
layout = new QHBoxLayout(ui->scrollAreaWidgetContents);
for(ResourcePreview *w : m_Thumbnails)
layout->addWidget(w);
layout->setSpacing(6);
layout->setContentsMargins(6, 6, 6, 6);
layout->setAlignment(Qt::AlignTop);
int noscrollWidth = numActive * (aspectWidth + 20);
if(noscrollWidth <= avail.width())
{
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
for(ResourcePreview *c : m_Thumbnails)
c->setSize(QSize(aspectWidth, avail.height()));
}
else
{
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
QScrollBar *hs = ui->scrollArea->horizontalScrollBar();
avail.setHeight(avail.height() - hs->geometry().height());
aspectWidth = (int)((float)avail.height() * 1.3f);
int totalWidth = numActive * (aspectWidth + 20);
hs->setEnabled(totalWidth > avail.width());
for(ResourcePreview *c : m_Thumbnails)
c->setSize(QSize(aspectWidth, avail.height()));
}
}
else
{
avail.setHeight(avail.height() + 6); // controls implicitly have a 6 margin on the bottom
int aspectHeight = (int)((float)avail.width() / 1.3f);
ui->scrollArea->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
delete layout;
layout = new QVBoxLayout(ui->scrollAreaWidgetContents);
for(ResourcePreview *w : m_Thumbnails)
layout->addWidget(w);
layout->setSpacing(6);
layout->setContentsMargins(6, 6, 6, 6);
layout->setAlignment(Qt::AlignTop);
int noscrollHeight = numActive * (aspectHeight + 6);
if(noscrollHeight <= avail.height())
{
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
for(ResourcePreview *c : m_Thumbnails)
c->setSize(QSize(avail.width(), aspectHeight));
}
else
{
ui->scrollArea->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn);
QScrollBar *vs = ui->scrollArea->verticalScrollBar();
avail.setWidth(avail.width() - vs->geometry().width());
aspectHeight = (int)((float)avail.width() / 1.3f);
int totalHeight = numActive * (aspectHeight + 6);
vs->setEnabled(totalHeight > avail.height());
for(ResourcePreview *c : m_Thumbnails)
c->setSize(QSize(avail.width(), aspectHeight));
}
}
}
示例2: 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);
//---------
//.........这里部分代码省略.........