本文整理汇总了C++中QSlider::setFocusPolicy方法的典型用法代码示例。如果您正苦于以下问题:C++ QSlider::setFocusPolicy方法的具体用法?C++ QSlider::setFocusPolicy怎么用?C++ QSlider::setFocusPolicy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSlider
的用法示例。
在下文中一共展示了QSlider::setFocusPolicy方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: QWidget
QWidget *dSettingWindow::createWidget()
{
QWidget * widget = new QWidget();
QVBoxLayout *layout = new QVBoxLayout;
layout->setMargin(1);
layout->setSpacing(5);
layout->addWidget( new QLabel("Непрозрачноть окна (заначения от 0 до 100).<br>Прозрачные окна имеют проблемы с прорисовкой!") );
QSpinBox *opacitySpinBox = new QSpinBox;
opacitySpinBox->setRange(30, 100);
opacitySpinBox->setSingleStep(1);
opacitySpinBox->setValue(int(window->windowOpacity()*100));
connect(opacitySpinBox, SIGNAL(valueChanged(int)), this, SLOT(opacityValueChanged(int)));
QSlider *opacitySlider = new QSlider(Qt::Horizontal);
opacitySlider->setFocusPolicy(Qt::StrongFocus);
opacitySlider->setTickPosition(QSlider::TicksBothSides);
opacitySlider->setTickInterval(10);
opacitySlider->setSingleStep(1);
opacitySlider->setMaximum ( 100 );
opacitySlider->setMinimum ( 30 );
opacitySlider->setValue(opacitySpinBox->value());
connect(opacitySlider, SIGNAL(valueChanged(int)), opacitySpinBox, SLOT(setValue(int)));
connect(opacitySpinBox, SIGNAL(valueChanged(int)), opacitySlider, SLOT(setValue(int)));
QHBoxLayout *opacityLayout = new QHBoxLayout;
opacityLayout->setSpacing(15);
opacityLayout->addWidget( opacitySpinBox );
opacityLayout->addWidget( opacitySlider );
layout->addItem( opacityLayout );
layout->addWidget( new QLabel("Изменение рамки окна. Есть возможность использовать стандартное окно,<br> но тогда пропадет эффект \"магнетизма\" окон.") );
QHBoxLayout *skinLayout = new QHBoxLayout;
skinLayout->setSpacing(15);
skinPushButton = new QPushButton(tr("Load skin"));
skinPushButton->setDefault(true);
skinPushButton->setIcon(QIcon(tr("pic/open32x32.png")));
connect(skinPushButton, SIGNAL(clicked(bool)), this, SLOT(clickedSkinButton(bool)));
skinLayout->addWidget( skinPushButton );
QCheckBox *standartFrameCheckBox = new QCheckBox(tr("Стандартная рамка окна"));
connect(standartFrameCheckBox, SIGNAL(stateChanged(int)), this, SLOT(stateChanged(int)));
skinLayout->addWidget( standartFrameCheckBox );
skinLayout->addStretch ( 1 );
layout->addItem(skinLayout);
widget->setLayout(layout);
return widget;
};
示例2: QSlider
/*!
* Creates and returns a new horizontal slider with range from [min] to [max],
* value [value] and single step size [step], adds it to [layout] if it is not
* NULL, and sets it for no focus. The page step and single step are both set
* to 1.
*/
QSlider *diaSlider(int min, int max, int step, int value,
QWidget *parent, QBoxLayout *layout)
{
QSlider *slider = new QSlider(parent);
if (layout)
layout->addWidget(slider);
slider->setOrientation(Qt::Horizontal);
slider->setRange(min, max);
slider->setSingleStep(step);
slider->setPageStep(step);
slider->setValue(value);
slider->setFocusPolicy(Qt::NoFocus);
return slider;
}