38 inline void setIndex(
int newIndex) { indexInPage = newIndex; }
77 typedef std::vector<std::unique_ptr<Page>>
PageList;
144 after = tB == lastButton;
152 if (!
icon().isNull()) {
166 return QSize(icone + 8, icone + 8);
182 const int widgetCount = toolBox->
count();
184 if (widgetCount == 1) {
186 }
else if (indexInPage == 0) {
188 }
else if (indexInPage == widgetCount - 1) {
193 if (currIndex == indexInPage - 1) {
195 }
else if (currIndex == indexInPage + 1) {
265 d->layout->setContentsMargins(
QMargins());
316 auto newPage = std::make_unique<QToolBoxPrivate::Page>();
320 c.button->setObjectName(
"qt_toolbox_toolboxbutton"_L1);
325 c.sv->setWidgetResizable(
true);
332 if (index < 0 || index >=
static_cast<int>(
d->pageList.size())) {
333 index =
static_cast<int>(
d->pageList.size());
334 d->pageList.push_back(std::move(newPage));
335 d->layout->addWidget(
c.button);
336 d->layout->addWidget(
c.sv);
340 d->pageList.insert(
d->pageList.cbegin() +
index, std::move(newPage));
342 if (
d->currentPage) {
343 QWidget *current =
d->currentPage->widget;
344 int oldindex =
indexOf(current);
345 if (
index <= oldindex) {
346 d->currentPage =
nullptr;
365 if (
page->button == tb) {
371 q->setCurrentIndex(
q->indexOf(
item));
384 return static_cast<int>(
d->pageList.size());
391 if (!
c ||
d->currentPage ==
c)
394 c->button->setSelected(
true);
395 if (
d->currentPage) {
396 d->currentPage->sv->hide();
397 d->currentPage->button->setSelected(
false);
400 d->currentPage->sv->show();
418 return [
page](
const std::unique_ptr<QToolBoxPrivate::Page> &
ptr) {
433 c->sv->deleteLater();
441 emit q->currentChanged(-1);
442 }
else if (removeCurrent) {
444 q->setCurrentIndex(0);
460 d->_q_widgetDestroyed(
w);
479 return d->currentPage ?
indexOf(
d->currentPage->widget) : -1;
492 return d->currentPage ?
d->currentPage->widget :
nullptr;
504 qWarning(
"QToolBox::setCurrentWidget: widget not contained in tool box");
517 if (index < 0 || index >=
static_cast<int>(
d->pageList.size()))
519 return d->pageList[
index]->widget;
533 const auto it = std::find_if(
d->pageList.cbegin(),
d->pageList.cend(),
pageEquals(
c));
534 if (
it ==
d->pageList.cend())
536 return static_cast<int>(
it -
d->pageList.cbegin());
553 int curIndexUp =
index;
554 int curIndexDown = curIndexUp;
555 const int count =
static_cast<int>(
d->pageList.size());
556 while (curIndexUp > 0 || curIndexDown <
count-1) {
557 if (curIndexDown <
count-1) {
558 if (
d->page(++curIndexDown)->button->isEnabled()) {
559 index = curIndexDown;
563 if (curIndexUp > 0) {
564 if (
d->page(--curIndexUp)->button->isEnabled()) {
607#if QT_CONFIG(tooltip)
612void QToolBox::setItemToolTip(
int index,
const QString &toolTip)
617 c->setToolTip(toolTip);
629 return c &&
c->button->isEnabled();
653 return (
c ?
c->icon() :
QIcon());
656#if QT_CONFIG(tooltip)
715#include "moc_qtoolbox.cpp"
716#include "qtoolbox.moc"
void addWidget(QWidget *, int stretch=0, Qt::Alignment alignment=Qt::Alignment())
Adds widget to the end of this box layout, with a stretch factor of stretch and alignment alignment.
Type type() const
Returns the event type.
QSize size(int flags, const QString &str, int tabstops=0, int *tabarray=nullptr) const
Returns the size in pixels of text.
The QFrame class is the base class of widgets that can have a frame.
bool event(QEvent *e) override
\reimp
void changeEvent(QEvent *) override
\reimp
The QIcon class provides scalable icons in different modes and states.
void removeWidget(QWidget *w)
Removes the widget widget from the layout.
void setContentsMargins(int left, int top, int right, int bottom)
QObject * parent() const
Returns a pointer to the parent object.
static QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
\threadsafe
void destroyed(QObject *=nullptr)
This signal is emitted immediately before the object obj is destroyed, after any instances of QPointe...
The QPaintEvent class contains event parameters for paint events.
The QPainter class performs low-level painting on widgets and other paint devices.
The QPalette class contains color groups for each widget state.
const QColor & color(ColorGroup cg, ColorRole cr) const
Returns the color in the specified color group, used for the given color role.
void setColor(ColorGroup cg, ColorRole cr, const QColor &color)
Sets the color in the specified color group, used for the given color role, to the specified solid co...
The QShowEvent class provides an event that is sent when a widget is shown.
constexpr int height() const noexcept
Returns the height.
constexpr int width() const noexcept
Returns the width.
\macro QT_RESTRICTED_CAST_FROM_ASCII
virtual void drawControl(ControlElement element, const QStyleOption *opt, QPainter *p, const QWidget *w=nullptr) const =0
Draws the given element with the provided painter with the style options specified by option.
virtual int pixelMetric(PixelMetric metric, const QStyleOption *option=nullptr, const QWidget *widget=nullptr) const =0
Returns the value of the given pixel metric.
The QVBoxLayout class lines up widgets vertically.
QSet< QString >::iterator it
Combined button and popup list for selecting options.
static ControlElement< T > * ptr(QWidget *widget)
constexpr const T & qMax(const T &a, const T &b)
GLboolean GLboolean GLboolean b
GLfloat GLfloat GLfloat w
[0]
GLenum GLenum GLsizei count
GLenum GLenum GLsizei const GLuint GLboolean enabled
GLdouble GLdouble GLdouble GLdouble q
decorationRoleName setToolTip
myObject disconnect()
[26]
void setIcon(const QIcon &is)
bool operator==(const Page &other) const
void setText(const QString &text)
IUIAutomationTreeWalker __RPC__deref_out_opt IUIAutomationElement ** parent