本文整理汇总了C++中QBoxLayout::addSpacerItem方法的典型用法代码示例。如果您正苦于以下问题:C++ QBoxLayout::addSpacerItem方法的具体用法?C++ QBoxLayout::addSpacerItem怎么用?C++ QBoxLayout::addSpacerItem使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBoxLayout
的用法示例。
在下文中一共展示了QBoxLayout::addSpacerItem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tr
HelpWindow::HelpWindow( QWidget * parent ) :
QWidget( parent )
{
setWindowTitle( tr("Help") );
setWindowOpacity( 0.8 );
QBoxLayout * layout = new QBoxLayout( QBoxLayout::TopToBottom, this );
layout->addWidget( new QLabel("Controls:\n\nW: Walk forward\nS: Walk backward\nA: Walk left\nD: Walk right\n\nMouse: View\nLeft Mouse: Fire") );
layout->addSpacerItem( new QSpacerItem( 50, 1, QSizePolicy::Expanding, QSizePolicy::Expanding ) );
setLayout( layout );
}
示例2: insertSpacerItem
void tst_QBoxLayout::insertSpacerItem()
{
QWidget *window = new QWidget;
QSpacerItem *spacer1 = new QSpacerItem(20, 10, QSizePolicy::Expanding, QSizePolicy::Expanding);
QSpacerItem *spacer2 = new QSpacerItem(40, 20, QSizePolicy::Expanding, QSizePolicy::Expanding);
QBoxLayout *layout = new QHBoxLayout;
layout->addWidget(new QLineEdit("Foooooooooooooooooooooooooo"));
layout->addSpacerItem(spacer1);
layout->addWidget(new QLineEdit("Baaaaaaaaaaaaaaaaaaaaaaaaar"));
layout->insertSpacerItem(0, spacer2);
window->setLayout(layout);
QVERIFY(layout->itemAt(0) == spacer2);
QVERIFY(layout->itemAt(2) == spacer1);
window->show();
}
示例3: font
ShaderEdit::ShaderEdit( QWidget *parent, Parameter *p ) : ParameterWidget( parent, p ), progress( NULL )
{
box = new QBoxLayout( QBoxLayout::TopToBottom );
box->setContentsMargins( 0, 0, 0, 0 );
QBoxLayout *allLayout = new QBoxLayout( QBoxLayout::TopToBottom );
QBoxLayout *localLayout = new QBoxLayout( QBoxLayout::LeftToRight );
localComboLabel = new QLabel( tr("Available effects:") );
widgets.append( localComboLabel );
localLayout->addWidget( localComboLabel );
localShadersCombo = new QComboBox();
widgets.append( localShadersCombo );
localLayout->addWidget( localShadersCombo );
localLayout->addSpacerItem( new QSpacerItem( 10, 1 ) );
editCheckBox = new QCheckBox( tr("Edit...") );
widgets.append( editCheckBox );
localLayout->addWidget( editCheckBox );
localLayout->setStretch( 0, 1 );
localLayout->setStretch( 1, 1 );
localLayout->setStretch( 2, 2 );
allLayout->addLayout( localLayout );
editor = new QPlainTextEdit();
//QFont font = QFontDatabase::systemFont( QFontDatabase::FixedFont );
QFont font( "Sans" );
//font.setPointSize( 12 );
editor->setFont( font );
editor->setStyleSheet( "QPlainTextEdit{ background-color:#FFFEC7; color:black; }" );
editor->setTabStopWidth( QFontMetrics( font ).averageCharWidth() * 2 );
highlighter = new Highlighter( editor->document() );
widgets.append( editor );
allLayout->addWidget( editor );
editor->hide();
QBoxLayout *applyLayout = new QBoxLayout( QBoxLayout::LeftToRight );
applyBtn = new QPushButton( tr("Apply") );
applyBtn->hide();
widgets.append( applyBtn );
helpBtn = new QPushButton( tr("Help") );
helpBtn->hide();
widgets.append( helpBtn );
applyLayout->addWidget( applyBtn );
applyLayout->insertStretch( 1, 1 );
applyLayout->addWidget( helpBtn );
allLayout->addLayout( applyLayout );
localShadersGroup = new QGroupBox();
localShadersGroup->setLayout( allLayout );
box->addWidget( localShadersGroup );
editor->setPlainText( p->value.toString() );
applyBtn->setEnabled( false );
QStringList list = ShaderCollection::getGlobalInstance()->localShadersNames();
foreach( const QString & s, list )
localShadersCombo->addItem( s );
QString shaderName = Parameter::getShaderName( p->value.toString() );
for ( int i = 0; i < localShadersCombo->count(); ++i ) {
if ( localShadersCombo->itemText( i ) == shaderName ) {
localShadersCombo->setCurrentIndex( i );
break;
}
}
connect( editor, SIGNAL(textChanged()), this, SLOT(textChanged()) );
connect( editor, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged()) );
connect( applyBtn, SIGNAL(clicked()), this, SLOT(applyClicked()) );
connect( helpBtn, SIGNAL(clicked()), this, SLOT(helpClicked()) );
connect( editCheckBox, SIGNAL(stateChanged(int)), this, SLOT(showEditor(int)) );
connect( localShadersCombo, SIGNAL(activated(const QString&)), this, SLOT(localShaderChanged(const QString&)) );
}
示例4: addSpacerItem
void QBoxLayoutProto::addSpacerItem(QSpacerItem *spacerItem)
{
QBoxLayout *item = qscriptvalue_cast<QBoxLayout*>(thisObject());
if (item)
item->addSpacerItem(spacerItem);
}