当前位置: 首页>>代码示例>>C++>>正文


C++ QSlider类代码示例

本文整理汇总了C++中QSlider的典型用法代码示例。如果您正苦于以下问题:C++ QSlider类的具体用法?C++ QSlider怎么用?C++ QSlider使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了QSlider类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dlg

bool Widgets::slider( QWidget *parent, const QString& title, const QString& text, int minValue, int maxValue, int step, int &result )
{
    KDialog dlg( parent );
    kapp->setTopWidget( &dlg );
    dlg.setCaption( title );
    dlg.setButtons( KDialog::Ok|KDialog::Cancel );
    dlg.setModal( true );
    dlg.setDefaultButton( KDialog::Ok );

    KVBox* vbox = new KVBox( &dlg );
    dlg.setMainWidget( vbox );

    QLabel label (vbox);
    label.setText (text);
    QSlider slider (vbox);
    slider.setMinimum( minValue );
    slider.setMaximum( maxValue );
    slider.setSingleStep( step );
    slider.setTickPosition ( QSlider::TicksAbove );
    slider.setOrientation( Qt::Horizontal );
    handleXGeometry(&dlg);

    const bool retcode = (dlg.exec() == QDialog::Accepted);

    if (retcode)
        result = slider.value();

    return retcode;
}
开发者ID:vishesh,项目名称:kde-baseapps,代码行数:29,代码来源:widgets.cpp

示例2: QComboBox

QWidget* CameraParamsWidget::createEditorFor(const camera_v4l2::CameraParam& param)
{
	if(!param.choices.empty())
	{
		QComboBox* box = new QComboBox(m_w);
		for(uint i = 0; i < param.choices.size(); ++i)
		{
			box->addItem(
				param.choices[i].label.c_str(),
				param.choices[i].value
			);
			if(param.choices[i].value == param.value)
				box->setCurrentIndex(i);
		}

		box->setProperty("paramID", param.id);

		connect(box, SIGNAL(activated(int)), SLOT(updateComboBox()));

		return box;
	}

	if(param.minimum == 0 && param.maximum == 1)
	{
		QCheckBox* box = new QCheckBox(m_w);
		box->setChecked(param.value);

		box->setProperty("paramID", param.id);

		connect(box, SIGNAL(clicked(bool)), SLOT(updateCheckBox(bool)));

		return box;
	}

	QSlider* slider = new QSlider(Qt::Horizontal, m_w);
	slider->setMinimum(param.minimum);
	slider->setMaximum(param.maximum);
	slider->setValue(param.value);

	slider->setProperty("paramID", param.id);

	connect(slider, SIGNAL(valueChanged(int)), SLOT(updateSlider(int)));

	return slider;
}
开发者ID:NhatTanXT3,项目名称:humanoid_op_ros,代码行数:45,代码来源:cameraparamswidget.cpp

示例3: QWidget

MyWidget::MyWidget(QWidget *parent)
     : QWidget(parent)
 {
    setWindowTitle(tr("Test thread project"));
    setFixedSize(550, 420);

    bQuit = new QPushButton(tr("&Quit"));
    bRnd = new QPushButton ("&RND");
    bCountDown = new QPushButton ("&Start CountDown");

    bQuit->setFont(QFont("Courier", 18, QFont::Bold));
    bRnd->setFont(QFont("Courier", 18, QFont::Bold));
    bCountDown->setFont(QFont("Courier", 18, QFont::Bold));

    lcd = new QLCDNumber();
    lcd->setSegmentStyle(QLCDNumber::Filled);
    lcd->setAutoFillBackground(1);
    lcd->display(0);

    QSlider *slider = new QSlider(Qt::Horizontal);
    slider->setRange(0, 999);
    slider->setValue(0);

    // line3 =    new QLineEdit (this);
    lnMSTime = new QLineEdit (this);

    QVBoxLayout *layout = new QVBoxLayout;
    QHBoxLayout *hLayout = new QHBoxLayout;
    connect(bQuit, SIGNAL(clicked()), qApp, SLOT(quit()));
    
    connect(bCountDown, SIGNAL(clicked()), this, SLOT (StartMyThread()));
    connect(bRnd, SIGNAL(clicked ()), this, SLOT (setValue ()));
    connect(slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)));
    
    layout->addWidget(lcd);
    layout->addWidget(slider);
    layout->addWidget(lnMSTime);

    hLayout->addWidget(bRnd);
    hLayout->addWidget(bQuit);
    hLayout->addWidget(bCountDown);
    layout->addLayout(hLayout);
    
    setLayout(layout);
 }
开发者ID:MakSim345,项目名称:QT-Dev,代码行数:45,代码来源:mywidget.cpp

示例4: itEditor

void QtSliderFactory::slotRangeChanged(QtProperty *property, int min, int max)
{
    if (!m_createdEditors.contains(property))
        return;

    QtIntPropertyManager *manager = this->propertyManager(property);
    if (!manager)
        return;

    QListIterator<QSlider *> itEditor(m_createdEditors[property]);
    while (itEditor.hasNext()) {
        QSlider *editor = itEditor.next();
        editor->blockSignals(true);
        editor->setRange(min, max);
        editor->setValue(manager->value(property));
        editor->blockSignals(false);
    }
}
开发者ID:Masstronaut,项目名称:phantom-cpp,代码行数:18,代码来源:qteditorfactory.cpp

示例5: QVBox

ConnectWidget::ConnectWidget( QWidget *parent, const char *name) : QVBox(parent,name){
   QPushButton *button = new QPushButton("Sair",this,"quit");

   connect(button, SIGNAL(clicked()), qApp, SLOT(quit()));

   QLCDNumber *lcd = new QLCDNumber(2,this,"lcd");
   QSlider *slider = new QSlider(Horizontal,this,"Slider");
   slider->setRange(0, 99);
   slider->setValue(0);
   slider->setPageStep(1);

   connect( slider, SIGNAL(valueChanged(int)), lcd, SLOT(display(int)) );

   QPushButton *add = new QPushButton("Somar",this,"add");
   connect(add, SIGNAL(clicked()), slider, SLOT(addStep()));
   QPushButton *subtract = new QPushButton("Subtrair",this,"subtract");
   connect(subtract, SIGNAL(clicked()), slider, SLOT(subtractStep()));
} 
开发者ID:PotHix,项目名称:pothix-codes,代码行数:18,代码来源:tcc.cpp

示例6: GetWidget

void ParamWidget::SetDouble(const QString& name, double val) {
  QWidget* widget = GetWidget(name);
  QDoubleSpinBox* spinbox = dynamic_cast<QDoubleSpinBox*>(widget);
  if (spinbox) {
    spinbox->setValue(val);
    return;
  }
  QSlider* slider = dynamic_cast<QSlider*>(widget);
  if (slider) {
    const double min = slider->property("min").toDouble();
    const double step = slider->property("step").toDouble();
    const int position = static_cast<int>(round((val - min) / step));
    slider->setValue(position);
    return;
  }
  throw std::runtime_error("Unable to determine widget type for param " +
      name.toStdString());
}
开发者ID:ashuang,项目名称:sceneview,代码行数:18,代码来源:param_widget.cpp

示例7: initStyleOption

void QxtSpanSliderPrivate::handleMousePress(const QPoint& pos, QStyle::SubControl& control, int value, SpanHandle handle)
{
    QStyleOptionSlider opt;
    initStyleOption(&opt, handle);
    QSlider* p = &qxt_p();
    const QStyle::SubControl oldControl = control;
    control = p->style()->hitTestComplexControl(QStyle::CC_Slider, &opt, pos, p);
    const QRect sr = p->style()->subControlRect(QStyle::CC_Slider, &opt, QStyle::SC_SliderHandle, p);
    if (control == QStyle::SC_SliderHandle)
    {
        position = value;
        offset = pick(pos - sr.topLeft());
        lastPressed = handle;
        p->setSliderDown(true);
    }
    if (control != oldControl)
        p->update(sr);
}
开发者ID:01iv3r,项目名称:OpenPilot,代码行数:18,代码来源:qxtspanslider.cpp

示例8: QWidget

Console::Console(QWidget *parent) : QWidget(parent)
{
    QPushButton* NewWorld = new QPushButton("New world", this);
    NewWorld->setFixedSize(100, 30);

    connect(NewWorld, SIGNAL(clicked(bool)), parent, SLOT(SetNewWorld()));

    QPushButton* Load = new QPushButton("Load world", this);
    Load->setFixedSize(100, 30);

    fd_load = new QFileDialog(this, "Loading");
    fd_load->setFileMode(QFileDialog::ExistingFile);

    connect(Load, SIGNAL(clicked()), fd_load, SLOT(show()));
    connect(fd_load, SIGNAL(fileSelected(const QString&)), this, SLOT(FileChosenLoad(const QString&)));

    QPushButton* Save = new QPushButton("Save world", this);
    Save->setFixedSize(100, 30);

    connect(Save, SIGNAL(clicked()), parent, SLOT(SaveFile()));

    Pause = new QPushButton("Start", this);
    Pause->setFixedSize(100, 30);

    connect(Pause, SIGNAL(clicked(bool)), parent, SLOT(Pause()));
    connect(parent, SIGNAL(Paused(const QString&)), this, SLOT(ChangeText(const QString&)));

    QSlider* slider = new QSlider(this);
    slider->setRange(0, 500);
    slider->setValue(250);
    slider->setOrientation(Qt::Horizontal);
    connect(slider, SIGNAL(valueChanged(int)), parent, SLOT(SetPeriod(int)));

    QLabel* label = new QLabel("<p align = center>- Speed +</p>", this);

    QVBoxLayout* vl = new QVBoxLayout(this);
    vl->addWidget(NewWorld);
    vl->addWidget(Load);
    vl->addWidget(Save);
    vl->addWidget(Pause);
    vl->addWidget(slider);
    vl->addWidget(label);
    setLayout(vl);
}
开发者ID:An2An96,项目名称:World-Model,代码行数:44,代码来源:view.cpp

示例9: onElementSizeChanged

void MainWidget::onElementSizeChanged(int value)
{
	QSlider* notifier = qobject_cast<QSlider*>(sender());
	QSlider* fbslider;

	// Zdecyduj dla ktorej kontrolki wywolano zdarzenie
	if(notifier == hsXElementSize)
	{
		lbXElementSize->setText(QLatin1String("Horizontal: ") + 
			QString::number(2 * value + 1));
		fbslider = hsYElementSize;
	}
	else
	{
		lbYElementSize->setText(QString::fromLatin1("Vertical: ") + 
			QString::number(2 * value + 1));
		fbslider = hsXElementSize;
	}

	// Jesli mamy zaznaczone 1:1 ratio
	if (cbSquare->checkState() == Qt::Checked)
	{
		if (fbslider->value() != value)
		{
			disableRecomputing = true;
			fbslider->setValue(value);
		}
	}

	emit structuringElementChanged();

	// Czy trzeba ponownie wykonac obliczenia w zwiazku ze zmiana 
	// rozmiaru elementu strukturalnego
	if (!disableRecomputing)
	{
		if((cbAutoTrigger->isChecked() && !rbNone->isChecked()) ||
		   cameraOn)
		{
			emit recomputeNeeded();
		}
	}		

	disableRecomputing = false;
}
开发者ID:k0zmo,项目名称:morphology-opencl,代码行数:44,代码来源:mainwidget.cpp

示例10: 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; 
};
开发者ID:vasyaod,项目名称:dChat,代码行数:54,代码来源:dsettingwindow.cpp

示例11: setFixedSize

void MusicSoundKMicroSettingPopWidget::initWidget()
{
    setFixedSize(54, 24);
    setTranslucentBackground();

    m_recordCore = nullptr;
    m_containWidget->setFixedSize(310, 190);
    m_containWidget->setStyleSheet(MusicUIObject::MBackgroundStyle08 + MusicUIObject::MColorStyle03);

    QCheckBox *checkBox = new QCheckBox(tr("Hear Yourself Singing"), m_containWidget);
    checkBox->setGeometry(10, 20, 280, 25);
    checkBox->setStyleSheet(MusicUIObject::MCheckBoxStyle05);

    QCheckBox *checkBox2 = new QCheckBox(tr("Noise Elimination"), m_containWidget);
    checkBox2->setGeometry(10, 50, 280, 25);
    checkBox2->setStyleSheet(MusicUIObject::MCheckBoxStyle05);

#ifdef Q_OS_UNIX
    checkBox->setFocusPolicy(Qt::NoFocus);
    checkBox2->setFocusPolicy(Qt::NoFocus);
#endif

    QLabel *microIconLabel = new QLabel(m_containWidget);
    microIconLabel->setGeometry(10, 92, 26, 18);

    QSlider *slider = new QSlider(Qt::Horizontal, m_containWidget);
    slider->setGeometry(36, 90, 150, 25);
    slider->setStyleSheet(QString("QSlider{%1}").arg(MusicUIObject::MBackgroundStyle01) + MusicUIObject::MSliderStyle01);
    slider->setRange(0, 100);
    slider->setValue(100);
    connect(slider, SIGNAL(valueChanged(int)), SLOT(volumeChanged(int)));

    QLabel *inputLabel = new QLabel(tr("Input"), m_containWidget);
    inputLabel->setGeometry(10, 120, 50, 25);
    inputLabel->setStyleSheet(MusicUIObject::MBackgroundStyle01);
    m_inputComboBox = new QComboBox(m_containWidget);
    m_inputComboBox->setGeometry(60, 120, 230, 25);
    m_inputComboBox->setStyleSheet(MusicUIObject::MBorderStyle04);
    m_inputComboBox->setItemDelegate(new QStyledItemDelegate(m_inputComboBox));
    m_inputComboBox->view()->setStyleSheet(MusicUIObject::MScrollBarStyle01);
    foreach(const QAudioDeviceInfo &info, QAudioDeviceInfo::availableDevices(QAudio::AudioInput))
    {
        m_inputComboBox->addItem(info.deviceName());
    }
开发者ID:jinting6949,项目名称:TTKMusicplayer,代码行数:44,代码来源:musicsoundkmicrosettingpopwidget.cpp

示例12: connect

void 
UnicornVolumeSlider::installFilters()
{
    QToolButton* muteButton = findChild<QToolButton*>();
    if( muteButton )
        muteButton->installEventFilter( this );
    
    QSlider* volumeSlider = findChild<QSlider*>();
    if( volumeSlider )
    {
        volumeSlider->setOrientation( Qt::Vertical );
        volumeSlider->installEventFilter( this );
        connect( volumeSlider, SIGNAL(valueChanged(int)), SLOT(onVolumeValueChanged(int)));
    }
    
    setFixedWidth( 30 );
    layout()->setContentsMargins( 0, 10, 0, 10);
    setAutoFillBackground( false );
}
开发者ID:AICIDNN,项目名称:lastfm-desktop,代码行数:19,代码来源:UnicornVolumeSlider.cpp

示例13: on_instance_clicked

void ZerosEditor::on_instance_clicked(Metabot::Component *instance)
{
    auto anchor = instance->aboveAnchor();
    if (anchor) {
        auto anchors = robot->getAnchors();
        int n = 0;
        for (auto robotAnchor : anchors) {
            if (robotAnchor == anchor) {
                if (n < sliders.size()) {
                    this->activateWindow();
                    this->setFocus();
                    QSlider *slider = sliders[n];
                    slider->setFocus();
                }
            }
            n++;
        }
    }
}
开发者ID:RhobanProject,项目名称:MetabotStudio,代码行数:19,代码来源:ZerosEditor.cpp

示例14: sender

void AbstractCameraManager::on_propertyCheckbox_changed(int state) {
    if( selectedItem == NULL ) return;
    CameraProperty* prop = reinterpret_cast<CameraProperty*>( sender()->property("CameraProperty").value<quintptr>() );
    qDebug() << sender() << prop->getName().c_str();
    prop->setAuto(state == Qt::Checked);
    cameraTree_recursiveSetProperty(selectedItem, prop);

    //(de)activate slider
    if( prop->getType() == CameraManager::AUTOTRIGGER ) return;
    QSlider* slider =  reinterpret_cast<QSlider*>( sender()->property("TreeWidgetSlider").value<quintptr>() );
    qDebug() << "Qslider" << slider;
    if(state != Qt::Checked) {
        slider->setEnabled(true);
        slider->setValue(prop->getValueToSlider());
    } else {
        slider->setEnabled(false);
    }

}
开发者ID:Antoinephi,项目名称:Project-Norway,代码行数:19,代码来源:abstractcameramanager.cpp

示例15: ExpectNameNotFound

void ParamWidget::AddInt(const QString& name,
    int min, int max, int step, int initial_value,
    DisplayHint display_hint) {
  ExpectNameNotFound(name);

  if (display_hint == DisplayHint::kSpinBox) {
    QSpinBox* spinbox = new QSpinBox(this);
    spinbox->setRange(min, max);
    spinbox->setSingleStep(step);
    spinbox->setValue(initial_value);
    spinbox->setProperty("param_widget_type", kParamInt);
    widgets_[name] = spinbox;
    AddLabeledRow(name, spinbox);
    connect(spinbox,
        static_cast<void(QSpinBox::*)(int)>(&QSpinBox::valueChanged),
        [this, name](int val) {
          emit ParamChanged(name);
        });
  } else if (display_hint == DisplayHint::kSlider) {
    QWidget* row_widget = new QWidget(this);
    QHBoxLayout* row_hbox = new QHBoxLayout(row_widget);
    QSlider* slider = new QSlider(Qt::Horizontal, this);
    slider->setRange(min, max);
    slider->setSingleStep(step);
    slider->setValue(initial_value);
    slider->setProperty("param_widget_type", kParamInt);
    QLabel* label = new QLabel(this);
    label->setText(QString::number(initial_value));
    row_hbox->addWidget(new QLabel(name, this));
    row_hbox->addWidget(slider);
    row_hbox->addWidget(label);
    widgets_[name] = slider;
    layout_->addWidget(row_widget);
    connect(slider, &QSlider::valueChanged,
        [this, name, label](int value) {
          label->setText(QString::number(value));
          emit ParamChanged(name);
        });
  } else {
    throw std::invalid_argument("Invalid display hint");
  }
}
开发者ID:ashuang,项目名称:sceneview,代码行数:42,代码来源:param_widget.cpp


注:本文中的QSlider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。