本文整理汇总了C++中QBoxLayout::indexOf方法的典型用法代码示例。如果您正苦于以下问题:C++ QBoxLayout::indexOf方法的具体用法?C++ QBoxLayout::indexOf怎么用?C++ QBoxLayout::indexOf使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QBoxLayout
的用法示例。
在下文中一共展示了QBoxLayout::indexOf方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: indexOf
int QBoxLayoutProto::indexOf(QWidget *widget) const
{
QBoxLayout *item = qscriptvalue_cast<QBoxLayout*>(thisObject());
if (item)
return item->indexOf(widget);
return 0;
}
示例2: replaceWidget
void tst_QBoxLayout::replaceWidget()
{
QWidget w;
QBoxLayout *boxLayout = new QVBoxLayout(&w);
QLineEdit *replaceFrom = new QLineEdit;
QLineEdit *replaceTo = new QLineEdit;
boxLayout->addWidget(new QLineEdit());
boxLayout->addWidget(replaceFrom);
boxLayout->addWidget(new QLineEdit());
QCOMPARE(boxLayout->indexOf(replaceFrom), 1);
QCOMPARE(boxLayout->indexOf(replaceTo), -1);
boxLayout->replaceWidget(replaceFrom, replaceTo);
QCOMPARE(boxLayout->indexOf(replaceFrom), -1);
QCOMPARE(boxLayout->indexOf(replaceTo), 1);
}
示例3: stretchRequested
void TestBox::stretchRequested(int i) {
int val = stretch->itemData(i).value<int>();
QObject* pa = parent();
QWidget* parent = qobject_cast<QWidget*>(pa);
if (parent->layout()->inherits("QBoxLayout")) {
QBoxLayout* box = qobject_cast<QBoxLayout*>(parent->layout());
box->setStretch(box->indexOf(this), val);
}
/*else if (parent->layout()->inherits("QGridLayout")) {
QGridLayout* grid = qobject_cast<QGridLayout*>(parent->layout());
int index = grid->indexOf(this);
int row = index/2;
int col = index%2;
grid->setRowStretch(row, val);
grid->setColumnStretch(col, val);
}*/
}
示例4: replaceWidget
void replaceWidget(QWidget *a, QWidget *b)
{
if(!a) {
return;
}
QLayout *lo = rw_findLayoutOf(a);
if(!lo) {
return;
}
//printf("decided on this: %p\n", lo);
if(lo->inherits("QBoxLayout")) {
QBoxLayout *bo = (QBoxLayout *)lo;
int n = bo->indexOf(a);
bo->insertWidget(n+1, b);
delete a;
}
}
示例5: PositionElement
logical OControlLayout :: PositionElement (ODataWidget *pODataWidget, ADK_VertPos verti_pos, ADK_HoriPos hori_pos )
{
QBoxLayout *layout = NULL;
logical term = NO;
switch ( verti_pos )
{
case VPS_OuterTop :
switch ( hori_pos )
{
case HPS_OuterLeft : layout = ProvideCornerLayout(0,Qt::AlignBottom | Qt::AlignRight);
break;
case HPS_OuterRight : layout = ProvideCornerLayout(1,Qt::AlignBottom | Qt::AlignLeft);
break;
case HPS_InnerLeft : layout = ProvideTopLayout(Qt::AlignLeft);
break;
case HPS_InnerRight : layout = ProvideTopLayout(Qt::AlignRight);
break;
default : ;
}
break;
case VPS_InnerTop :
switch ( hori_pos )
{
case HPS_OuterLeft : layout = ProvideLeftLayout(Qt::AlignTop);
break;
case HPS_OuterRight : layout = ProvideRightLayout(Qt::AlignTop);
break;
default : ;
}
break;
case VPS_InnerBottom :
switch ( hori_pos )
{
case HPS_OuterLeft : layout = ProvideLeftLayout(Qt::AlignBottom);
break;
case HPS_OuterRight : layout = ProvideRightLayout(Qt::AlignBottom);
break;
default : ;
}
break;
case VPS_OuterBottom :
switch ( hori_pos )
{
case HPS_OuterLeft : layout = ProvideCornerLayout(2,Qt::AlignTop | Qt::AlignRight);
break;
case HPS_OuterRight : layout = ProvideCornerLayout(3,Qt::AlignTop | Qt::AlignLeft);
break;
case HPS_InnerLeft : layout = ProvideBottomLayout(Qt::AlignLeft);
break;
case HPS_InnerRight : layout = ProvideBottomLayout(Qt::AlignRight);
break;
default : ;
}
break;
default : ;
}
if ( layout && layout->indexOf(pODataWidget->WidgetQ()) < 0 )
layout->addWidget(pODataWidget->WidgetQ());
return(term);
}
示例6: QFileDialog
pFileDialog::pFileDialog( QWidget* parent, const QString& caption, const QString& directory, const QString& filter, bool textCodecEnabled, bool openReadOnlyEnabled )
: QFileDialog( parent, caption, directory, filter )
{
setFileMode( QFileDialog::AnyFile );
setOption( QFileDialog::DontUseNativeDialog );
// get grid layout
glDialog = qobject_cast<QGridLayout*>( layout() );
// assert on gridlayout
Q_ASSERT( glDialog );
// relook the dialog to be more friendly
QLabel* lLookIn = findChild<QLabel*>( "lookInLabel" );
QComboBox* cbLookIn = findChild<QComboBox*>( "lookInCombo" );
QToolButton* tbNewFolder = findChild<QToolButton*>( "newFolderButton" );
QAbstractItemView* sidebar = findChild<QAbstractItemView*>( "sidebar" );
QFrame* fFrame = findChild<QFrame*>( "frame" );
QBoxLayout* hLayout = 0;
// search layout containing tbNewFolder
foreach ( QLayout* layout, findChildren<QLayout*>() ) {
if ( layout->indexOf( tbNewFolder ) != -1 ) {
hLayout = qobject_cast<QBoxLayout*>( layout );
break;
}
}
if ( lLookIn ) {
lLookIn->setVisible( false );
}
if ( hLayout ) {
hLayout->setSpacing( 3 );
hLayout->insertStretch( hLayout->indexOf( tbNewFolder ) );
}
if ( cbLookIn && fFrame ) {
QBoxLayout* vLayout = qobject_cast<QBoxLayout*>( fFrame->layout() );
if ( vLayout ) {
vLayout->setSpacing( 3 );
vLayout->insertWidget( 0, cbLookIn );
if ( hLayout ) {
glDialog->removeItem( hLayout );
hLayout->setParent( 0 );
vLayout->insertLayout( 0, hLayout );
}
}
}
if ( sidebar ) {
QWidget* viewport = sidebar->viewport();
QPalette pal = viewport->palette();
pal.setColor( viewport->backgroundRole(), QColor( Qt::transparent ) );
viewport->setPalette( pal );
sidebar->setFrameStyle( QFrame::NoFrame | QFrame::Plain );
sidebar->setIconSize( QSize( 16, 16 ) );
}
// text codec
mTextCodecEnabled = true;
lCodec = new QLabel( tr( "Codec:" ), this );
cbCodec = new QComboBox( this );
cbCodec->addItems( pCoreUtils::textCodecs() );
setTextCodec( QTextCodec::codecForLocale()->name() );
glDialog->addWidget( lCodec, 4, 0 );
glDialog->addWidget( cbCodec, 4, 1 );
// read only
mOpenReadOnlyEnabled = true;
cbOpenReadOnly = new QCheckBox( tr( "Open in read only." ), this );
glDialog->addWidget( cbOpenReadOnly, 5, 1 );
// configuration
setTextCodecEnabled( textCodecEnabled );
setOpenReadOnlyEnabled( openReadOnlyEnabled );
}