diff --git a/components/qtmaterialflatbutton.cpp b/components/qtmaterialflatbutton.cpp
index 6f6ab48..a03f098 100644
--- a/components/qtmaterialflatbutton.cpp
+++ b/components/qtmaterialflatbutton.cpp
@@ -45,6 +45,7 @@ void QtMaterialFlatButtonPrivate::init()
iconPlacement = Material::LeftIcon;
overlayStyle = Material::GrayOverlay;
bgMode = Qt::TransparentMode;
+ textAlignment = Qt::AlignHCenter;
fixedRippleRadius = 64;
cornerRadius = 3;
baseOpacity = 0.13;
@@ -440,6 +441,20 @@ void QtMaterialFlatButton::setFixedRippleRadius(qreal radius)
setHasFixedRippleRadius(true);
}
+void QtMaterialFlatButton::setTextAlignment(Qt::Alignment alignment)
+{
+ Q_D(QtMaterialFlatButton);
+
+ d->textAlignment = alignment;
+}
+
+Qt::Alignment QtMaterialFlatButton::textAlignment() const
+{
+ Q_D(const QtMaterialFlatButton);
+
+ return d->textAlignment;
+}
+
/*!
* \reimp
*/
diff --git a/components/qtmaterialflatbutton.h b/components/qtmaterialflatbutton.h
index 4ce0eed..a74ab6a 100644
--- a/components/qtmaterialflatbutton.h
+++ b/components/qtmaterialflatbutton.h
@@ -78,6 +78,9 @@ public:
void setFixedRippleRadius(qreal radius);
+ void setTextAlignment(Qt::Alignment alignment);
+ Qt::Alignment textAlignment() const;
+
QSize sizeHint() const Q_DECL_OVERRIDE;
protected:
diff --git a/components/qtmaterialflatbutton_p.h b/components/qtmaterialflatbutton_p.h
index 3700c12..1ab3d22 100644
--- a/components/qtmaterialflatbutton_p.h
+++ b/components/qtmaterialflatbutton_p.h
@@ -28,6 +28,7 @@ public:
Material::ButtonIconPlacement iconPlacement;
Material::OverlayStyle overlayStyle;
Qt::BGMode bgMode;
+ Qt::Alignment textAlignment;
QColor backgroundColor;
QColor foregroundColor;
QColor overlayColor;
diff --git a/examples/flatbuttonsettingsform.ui b/examples/flatbuttonsettingsform.ui
index c4df4ee..8512661 100644
--- a/examples/flatbuttonsettingsform.ui
+++ b/examples/flatbuttonsettingsform.ui
@@ -19,7 +19,7 @@
0
0
549
- 281
+ 314
@@ -202,14 +202,14 @@
-
- -
+
-
Overlay opacity
- -
+
-
1.000000000000000
@@ -219,36 +219,57 @@
- -
+
-
Icon size
- -
+
-
- -
+
-
Font size
- -
+
-
- -
+
-
Button text
- -
+
-
+ -
+
+
+ Text alignment
+
+
+
+ -
+
+
-
+
+ Left
+
+
+ -
+
+ Center
+
+
+
+
-