KColumnResizer

Search for usage in LXR

#include <KColumnResizer>

Inheritance diagram for KColumnResizer:

Public Member Functions

 KColumnResizer (QObject *parent=nullptr)
 
void addWidget (QWidget *widget)
 
void addWidgetsFromLayout (QLayout *layout, int column=0)
 
void removeWidget (QWidget *widget)
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
QBindable< QStringbindableObjectName ()
 
bool blockSignals (bool block)
 
const QObjectListchildren () const const
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method) const const
 
bool disconnect (const QObject *receiver, const char *method) const const
 
void dumpObjectInfo () const const
 
void dumpObjectTree () const const
 
QList< QByteArraydynamicPropertyNames () const const
 
virtual bool event (QEvent *e)
 
findChild (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QRegularExpression &re, Qt::FindChildOptions options) const const
 
QList< T > findChildren (const QString &name, Qt::FindChildOptions options) const const
 
QList< T > findChildren (Qt::FindChildOptions options) const const
 
bool inherits (const char *className) const const
 
void installEventFilter (QObject *filterObj)
 
bool isQuickItemType () const const
 
bool isWidgetType () const const
 
bool isWindowType () const const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const const
 
void moveToThread (QThread *targetThread)
 
QString objectName () const const
 
void objectNameChanged (const QString &objectName)
 
QObjectparent () const const
 
QVariant property (const char *name) const const
 
 Q_CLASSINFO (Name, Value)
 
 Q_EMIT Q_EMIT
 
 Q_ENUM (...)
 
 Q_ENUM_NS (...)
 
 Q_ENUMS (...)
 
 Q_FLAG (...)
 
 Q_FLAG_NS (...)
 
 Q_FLAGS (...)
 
 Q_GADGET Q_GADGET
 
 Q_GADGET_EXPORT (EXPORT_MACRO)
 
 Q_INTERFACES (...)
 
 Q_INVOKABLE Q_INVOKABLE
 
 Q_MOC_INCLUDE Q_MOC_INCLUDE
 
 Q_NAMESPACE Q_NAMESPACE
 
 Q_NAMESPACE_EXPORT (EXPORT_MACRO)
 
 Q_OBJECT Q_OBJECT
 
 Q_PROPERTY (...)
 
 Q_REVISION Q_REVISION
 
 Q_SET_OBJECT_NAME (Object)
 
 Q_SIGNAL Q_SIGNAL
 
 Q_SIGNALS Q_SIGNALS
 
 Q_SLOT Q_SLOT
 
 Q_SLOTS Q_SLOTS
 
qobject_cast (const QObject *object)
 
qobject_cast (QObject *object)
 
 QT_NO_NARROWING_CONVERSIONS_IN_CONNECT QT_NO_NARROWING_CONVERSIONS_IN_CONNECT
 
void removeEventFilter (QObject *obj)
 
void setObjectName (const QString &name)
 
void setObjectName (QAnyStringView name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool setProperty (const char *name, QVariant &&value)
 
bool signalsBlocked () const const
 
int startTimer (int interval, Qt::TimerType timerType)
 
int startTimer (std::chrono::milliseconds interval, Qt::TimerType timerType)
 
QThreadthread () const const
 

Protected Member Functions

bool eventFilter (QObject *, QEvent *event) override
 
- Protected Member Functions inherited from QObject
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
bool isSignalConnected (const QMetaMethod &signal) const const
 
int receivers (const char *signal) const const
 
QObjectsender () const const
 
int senderSignalIndex () const const
 
virtual void timerEvent (QTimerEvent *event)
 

Additional Inherited Members

- Public Types inherited from QObject
typedef  QObjectList
 
- Properties inherited from QObject
 objectName
 
- Static Public Member Functions inherited from QObject
QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *context, Functor functor, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method, Qt::ConnectionType type)
 
QMetaObject::Connection connect (const QObject *sender, PointerToMemberFunction signal, Functor functor)
 
bool disconnect (const QMetaObject::Connection &connection)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
bool disconnect (const QObject *sender, PointerToMemberFunction signal, const QObject *receiver, PointerToMemberFunction method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 

Detailed Description

Maintains consistent column sizes across layouts.

KColumnResizer is a helper class which can force columns of different layouts to keep the same width. It is useful to keep label columns consistent.

It works with QGridLayout and QFormLayout.

left: without KColumnResizer - right: with KColumnResizer

Here is a typical example:

void Window::createWidgets()
{
QVBoxLayout *layout = new QVBoxLayout(this);
QGroupBox *box1 = new QGroupBox();
// Fill box1
// ...
layout->addWidget(box1);
QGroupBox *box2 = new QGroupBox();
// Fill box2
// ...
layout->addWidget(box2);
KColumnResizer *resizer = new KColumnResizer(this);
resizer->addWidgetsFromLayout(box1->layout(), 0);
resizer->addWidgetsFromLayout(box2->layout(), 0);
}
Maintains consistent column sizes across layouts.
void addWidgetsFromLayout(QLayout *layout, int column=0)
Add all widgets from layout which are in column column to the list of widgets to manage.
KColumnResizer(QObject *parent=nullptr)
Constructs a KColumnResizer.
void addWidget(QWidget *widget, int stretch, Qt::Alignment alignment)
QLayout * layout() const const

In this example box1 and box2 children can be organized using QGridLayout or QFormLayout, resizer will ensure the first columns of the two QGroupBox stay the same width.

Author
Aurélien Gâteau agate.nosp@m.au@k.nosp@m.de.or.nosp@m.g
Since
5.1

Definition at line 65 of file kcolumnresizer.h.

Constructor & Destructor Documentation

◆ KColumnResizer()

KColumnResizer::KColumnResizer ( QObject * parent = nullptr)
explicit

Constructs a KColumnResizer.

Definition at line 174 of file kcolumnresizer.cpp.

Member Function Documentation

◆ addWidget()

void KColumnResizer::addWidget ( QWidget * widget)

Add a single widget to the list of widgets whose width is monitored.

It is more common to use addWidgetsFromLayout(), but adding single widgets can be useful if you want to keep a single button the same width as a column in a layout.

Parameters
widgetThe widget to add

Definition at line 182 of file kcolumnresizer.cpp.

◆ addWidgetsFromLayout()

void KColumnResizer::addWidgetsFromLayout ( QLayout * layout,
int column = 0 )

Add all widgets from layout which are in column column to the list of widgets to manage.

Parameters
layoutThe layout containing the widgets to add. KColumnResizer supports QGridLayout and QFormLayout.
columnThe column number which contains the widgets. If layout is a QFormLayout, column should not be higher than QFormLayout::SpanningRole

Definition at line 209 of file kcolumnresizer.cpp.

◆ eventFilter()

bool KColumnResizer::eventFilter ( QObject * ,
QEvent * event )
overrideprotectedvirtual

Reimplemented from QObject.

Definition at line 201 of file kcolumnresizer.cpp.

◆ removeWidget()

void KColumnResizer::removeWidget ( QWidget * widget)

Remove a widget previously added by addWidget or addWidgetsFromLayout.

Parameters
widgetThe widget to remove

Definition at line 192 of file kcolumnresizer.cpp.


The documentation for this class was generated from the following files:
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Oct 4 2024 12:05:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.