void PropertyToolBox::addPage( QWidget* page ) { QBoxLayout* pageLayout = qobject_cast<QBoxLayout*>( page->layout() ); if ( pageLayout && pageLayout->direction() == QBoxLayout::TopToBottom ) { pageLayout->setContentsMargins( 5, 5, 5, 5 ); pageLayout->setSpacing( 3 ); for ( int i = 0; i < pageLayout->count(); i++ ) { QLayoutItem* item = pageLayout->itemAt( i ); if ( item->spacerItem() ) continue; QLabel* label = qobject_cast<QLabel*>( item->widget() ); if ( label ) { QString style = "border: none; border-bottom: 1px solid palette(dark);"; if ( i > 0 ) style += "margin-top: 2px;"; label->setStyleSheet( style ); continue; } QBoxLayout* itemLayout = qobject_cast<QBoxLayout*>( item->layout() ); if ( itemLayout && itemLayout->direction() == QBoxLayout::LeftToRight ) { itemLayout->insertSpacing( 0, 10 ); } else { pageLayout->removeItem( item ); QHBoxLayout* wrapperLayout = new QHBoxLayout(); wrapperLayout->addSpacing( 10 ); wrapperLayout->addItem( item ); pageLayout->insertLayout( i, wrapperLayout ); } } } page->setBackgroundRole( QPalette::Base ); addItem( page, page->windowTitle() ); }
void QBoxLayoutProto::insertSpacing(int index, int size) { QBoxLayout *item = qscriptvalue_cast<QBoxLayout*>(thisObject()); if (item) item->insertSpacing(index, size); }