Permalink
Show file tree
Hide file tree
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add new custom widgets (QgsSlider and QgsDial)
Modified versions of QSlider and QDial which show the current value Fix #4417
- Loading branch information
1 parent
2e4275d
commit 373ec56
Showing
5 changed files
with
76 additions
and
0 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,19 @@ | ||
#include "qgsdial.h" | ||
|
||
#include <QRect> | ||
|
||
QgsDial::QgsDial( QWidget *parent ) : QDial( parent ) | ||
{ | ||
setMinimumSize( QSize(50, 50) ); | ||
} | ||
|
||
void QgsDial::paintEvent( QPaintEvent *event ) | ||
{ | ||
QDial::paintEvent( event ); | ||
QPainter painter( this ); | ||
QRect rect = geometry(); | ||
painter.setPen( QPen( palette().color( QPalette::WindowText ) ) ); | ||
painter.drawText( QRectF( 0, rect.height() * 0.65, rect.width(), rect.height() ), | ||
Qt::AlignHCenter, QString::number( value() ), 0 ); | ||
painter.end(); | ||
} |
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,13 @@ | ||
#include <QDial> | ||
#include <QPainter> | ||
#include <QPaintEvent> | ||
#include <QSize> | ||
|
||
class QgsDial : public QDial | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsDial( QWidget *parent = 0 ); | ||
protected: | ||
virtual void paintEvent( QPaintEvent * event ); | ||
}; |
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,24 @@ | ||
#include "qgsslider.h" | ||
|
||
#include <QRect> | ||
|
||
QgsSlider::QgsSlider ( QWidget * parent ) : QSlider ( parent ) | ||
{ | ||
setMinimumSize( QSize(100, 40) ); | ||
} | ||
|
||
QgsSlider::QgsSlider( Qt::Orientation orientation, QWidget * parent) : QSlider( orientation, parent ) | ||
{ | ||
setMinimumSize( QSize(100, 40) ); | ||
} | ||
|
||
void QgsSlider::paintEvent( QPaintEvent *event ) | ||
{ | ||
QSlider::paintEvent( event ); | ||
QPainter painter( this ); | ||
QRect rect = geometry(); | ||
painter.setPen( QPen( palette().color( QPalette::WindowText ) ) ); | ||
painter.drawText( QRectF( 0, rect.height() * 0.5, rect.width(), rect.height() ), | ||
Qt::AlignHCenter, QString::number( value() ), 0 ); | ||
painter.end(); | ||
} |
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,14 @@ | ||
#include <QPainter> | ||
#include <QPaintEvent> | ||
#include <QSize> | ||
#include <QSlider> | ||
|
||
class QgsSlider : public QSlider | ||
{ | ||
Q_OBJECT | ||
public: | ||
QgsSlider( QWidget *parent = 0 ); | ||
QgsSlider( Qt::Orientation orientation, QWidget * parent = 0 ); | ||
protected: | ||
virtual void paintEvent( QPaintEvent * event ); | ||
}; |