-
-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
It's showed as mini button on part list widget, this parameter can be use to make fish body like mesh.
- Loading branch information
Showing
15 changed files
with
182 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <QtWidgets> | ||
#include "floatnumberwidget.h" | ||
|
||
FloatNumberWidget::FloatNumberWidget(QWidget *parent) : | ||
QWidget(parent) | ||
{ | ||
m_slider = new QSlider(Qt::Horizontal, this); | ||
m_slider->setRange(0, 100); | ||
|
||
m_label = new QLabel(this); | ||
m_label->setAlignment(Qt::AlignCenter); | ||
m_label->setNum(0); | ||
m_label->setFixedWidth(30); | ||
|
||
connect(m_slider, &QAbstractSlider::valueChanged, [=](int value) { | ||
float fvalue = value / 100.0; | ||
m_label->setText(QString().sprintf("%.2f", fvalue)); | ||
emit valueChanged(fvalue); | ||
}); | ||
|
||
QBoxLayout *popupLayout = new QHBoxLayout(this); | ||
popupLayout->setMargin(2); | ||
popupLayout->addWidget(m_slider); | ||
popupLayout->addWidget(m_label); | ||
} | ||
|
||
void FloatNumberWidget::setRange(float min, float max) | ||
{ | ||
m_slider->setRange(min * 100, max * 100); | ||
} | ||
|
||
void FloatNumberWidget::increaseValue() | ||
{ | ||
m_slider->triggerAction(QSlider::SliderPageStepAdd); | ||
} | ||
|
||
void FloatNumberWidget::descreaseValue() | ||
{ | ||
m_slider->triggerAction(QSlider::SliderPageStepSub); | ||
} | ||
|
||
float FloatNumberWidget::value() const | ||
{ | ||
return m_slider->value() / 100.0; | ||
} | ||
|
||
void FloatNumberWidget::setValue(float value) | ||
{ | ||
m_slider->setValue(value * 100); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef FLOAT_NUMBER_WIDGET_H | ||
#define FLOAT_NUMBER_WIDGET_H | ||
#include <QToolButton> | ||
|
||
QT_FORWARD_DECLARE_CLASS(QLabel) | ||
QT_FORWARD_DECLARE_CLASS(QSlider) | ||
|
||
class FloatNumberWidget : public QWidget | ||
{ | ||
Q_OBJECT | ||
public: | ||
explicit FloatNumberWidget(QWidget *parent = nullptr); | ||
void setRange(float min, float max); | ||
float value() const; | ||
|
||
public slots: | ||
void increaseValue(); | ||
void descreaseValue(); | ||
void setValue(float value); | ||
|
||
signals: | ||
void valueChanged(float value); | ||
|
||
private: | ||
QLabel *m_label = nullptr; | ||
QSlider *m_slider = nullptr; | ||
}; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.