maxLibQt
OverlayStackLayout.h
Go to the documentation of this file.
1 /*
2  OverlayStackLayout
3  https://github.com/mpaperno/maxLibQt
4 
5  COPYRIGHT: (c)2019 Maxim Paperno; All Right Reserved.
6  Contact: http://www.WorldDesign.com/contact
7 
8  LICENSE:
9 
10  Commercial License Usage
11  Licensees holding valid commercial licenses may use this file in
12  accordance with the terms contained in a written agreement between
13  you and the copyright holder.
14 
15  GNU General Public License Usage
16  Alternatively, this file may be used under the terms of the GNU
17  General Public License as published by the Free Software Foundation,
18  either version 3 of the License, or (at your option) any later version.
19 
20  This program is distributed in the hope that it will be useful,
21  but WITHOUT ANY WARRANTY; without even the implied warranty of
22  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  GNU General Public License for more details.
24 
25  A copy of the GNU General Public License is available at <http://www.gnu.org/licenses/>.
26 */
27 
28 #ifndef OVERLAYSTACKLAYOUT_H
29 #define OVERLAYSTACKLAYOUT_H
30 
31 #include <QStackedLayout>
32 
109 {
110  Q_OBJECT
111  public:
114  explicit OverlayStackLayout(QWidget *parent = nullptr);
116  explicit OverlayStackLayout(QLayout *parentLayout);
117 
123  int insertWidget(int index, QWidget *widget, Qt::Alignment alignment, const QPoint &offset);
130  int addWidget(QWidget *widget, Qt::Alignment alignment, const QPoint &offset);
133 
134  void setGeometry(const QRect &geo) override;
135 
136  public slots:
141  void setOffset(QWidget *widget, const QPoint &offset) const;
144  void setSenderOffset(const QPoint &offset) const;
147  void setSenderAlignment(Qt::Alignment align);
148 
155  void setStackingMode(StackingMode mode);
156 
157  private slots:
158  void doLayout() const;
159 
160  private:
161  Q_DISABLE_COPY(OverlayStackLayout)
162 };
163 
164 inline
166 {
167  return insertWidget(count(), widget, alignment);
168 }
169 
170 inline
171 int OverlayStackLayout::addWidget(QWidget *widget, Qt::Alignment alignment, const QPoint &offset)
172 {
173  return insertWidget(count(), widget, alignment, offset);
174 }
175 
176 #endif // OVERLAYSTACKLAYOUT_H
int addWidget(QWidget *widget, Qt::Alignment alignment)
Add widget to the stack with specified alignment.
int insertWidget(int index, QWidget *widget)
virtual QWidget * widget()
void setSenderAlignment(Qt::Alignment align)
Convenience slot to set the layout alignment on a signal from a QWidget::sender().
void setOffset(QWidget *widget, const QPoint &offset) const
Set the layout position offset coordinates for given widget.
typedef Alignment
void setStackingMode(StackingMode mode)
Re-implemented (shadowing) QStackedLayout::setStackingMode() to ensure proper child visibility.
void setSenderOffset(const QPoint &offset) const
Convenience slot to set the layout position offset on a signal from a QWidget::sender().
int insertWidget(int index, QWidget *widget, Qt::Alignment alignment)
Insert widget into the stack at index position with specified alignment.
void setGeometry(const QRect &geo) override
The OverlayStackLayout re-implements a QStackedLayout with additional features to allow stacks with "...
Qt::Alignment alignment() const const
OverlayStackLayout(QWidget *parent=nullptr)
Constructs a new OverlayStackLayout with the optional parent widget.
int addWidget(QWidget *widget)
QObject * parent() const const
virtual int count() const const override