本文整理汇总了C++中QLayoutIterator::current方法的典型用法代码示例。如果您正苦于以下问题:C++ QLayoutIterator::current方法的具体用法?C++ QLayoutIterator::current怎么用?C++ QLayoutIterator::current使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QLayoutIterator
的用法示例。
在下文中一共展示了QLayoutIterator::current方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: printLegend
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const
{
if ( !d_legend || d_legend->isEmpty() )
return;
QLayout *l = d_legend->contentsWidget()->layout();
if ( l == 0 || !l->inherits("QwtDynGridLayout") )
return;
QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l;
uint numCols = legendLayout->columnsForWidth(rect.width());
QValueList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
int index = 0;
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator)
{
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipping(TRUE);
QwtPainter::setClipRect(painter, itemRects[index]);
printLegendItem(painter, w, itemRects[index]);
index++;
painter->restore();
}
}
}
示例2: invalidateRecursive
static void invalidateRecursive( QLayoutItem *lay )
{
lay->invalidate();
QLayoutIterator it = lay->iterator();
QLayoutItem *child;
while ( (child = it.current() ) ) {
invalidateRecursive( child );
++it;
}
}
示例3: setShownDim
/** Set the shown dimension
*
* @param dim :: -1 = None, 0 = X, 1 = Y. 2+ reserved for higher dimensions
*/
void DimensionSliceWidget::setShownDim(int dim)
{
m_shownDim = dim;
ui.btnX->blockSignals(true);
ui.btnY->blockSignals(true);
ui.btnX->setChecked( m_shownDim == 0 );
ui.btnY->setChecked( m_shownDim == 1 );
ui.btnX->blockSignals(false);
ui.btnY->blockSignals(false);
/// Slice if dimension is not X or Y AND is not integrated
bool slicing = (m_shownDim == -1 && !m_dim->getIsIntegrated());
ui.horizontalSlider->setVisible( slicing );
ui.doubleSpinBox->setVisible( slicing );
ui.lblUnits->setVisible( slicing );
// Make the spacer expand to keep the buttons in the same spot
if (slicing)
{
if (ui.horizontalSpacer != NULL)
{
// Remove the 3rd item (if it's not gone already) = the spacer
QLayoutIterator it = ui.horizontalLayout->iterator();
++it; ++it; ++it;
ui.horizontalLayout->removeItem(it.current());
delete ui.horizontalSpacer;
ui.horizontalSpacer = NULL;
}
}
else
{
// Put the spacer back, if needed
if (ui.horizontalSpacer == NULL)
{
ui.horizontalSpacer = new QSpacerItem(1, 1, QSizePolicy::Expanding, QSizePolicy::Minimum);
ui.horizontalLayout->insertSpacerItem(3, ui.horizontalSpacer );
}
}
// Hide or show the rebinning controls
ui.spinBins->setVisible(m_showRebinControls && !slicing);
ui.spinThickness->setVisible(m_showRebinControls && slicing);
ui.lblRebinInfo->setVisible(m_showRebinControls);
if (slicing)
ui.lblRebinInfo->setText("thick");
else
ui.lblRebinInfo->setText("bins");
this->update();
}
示例4: setTextSpacer
void QGroupBox::setTextSpacer()
{
if ( !d->spacer )
return;
int h = 0;
int w = 0;
if ( isCheckable() || lenvisible ) {
QFontMetrics fm = fontMetrics();
int fh = fm.height();
if ( isCheckable() ) {
#ifndef QT_NO_CHECKBOX
fh = d->checkbox->sizeHint().height() + 2;
w = d->checkbox->sizeHint().width() + 2*fm.width( "xx" );
#endif
} else {
fh = fm.height();
w = fm.width( str, lenvisible ) + 2*fm.width( "xx" );
}
h = frameRect().y();
if ( layout() ) {
int m = layout()->margin();
int sp = layout()->spacing();
// do we have a child layout?
for ( QLayoutIterator it = layout()->iterator(); it.current(); ++it ) {
if ( it.current()->layout() ) {
m += it.current()->layout()->margin();
sp = QMAX( sp, it.current()->layout()->spacing() );
break;
}
}
h = QMAX( fh-m, h );
h += QMAX( sp - (h+m - fh), 0 );
}
}
d->spacer->changeSize( w, h, QSizePolicy::Minimum, QSizePolicy::Fixed );
}
示例5: if
QLayout *rw_recurseFindLayout(QLayout *lo, QWidget *w)
{
//printf("scanning layout: %p\n", lo);
QLayoutIterator it = lo->iterator();
for(QLayoutItem *i; (i = it.current()); ++it) {
//printf("found: %p,%p\n", i->layout(), i->widget());
QLayout *slo = i->layout();
if(slo) {
QLayout *tlo = rw_recurseFindLayout(slo, w);
if(tlo)
return tlo;
}
else if(i->widget() == w)
return lo;
}
return 0;
}
示例6: removeWidget
static bool removeWidget( QLayoutItem *lay, QWidget *w )
{
bool foo = FALSE;
QLayoutIterator it = lay->iterator();
QLayoutItem *child;
while ( (child = it.current() ) ) {
if ( child->widget() == w ) {
it.deleteCurrent();
lay->invalidate();
foo = TRUE;
} else if ( removeWidget( child, w ) ) {
lay->invalidate();
foo = TRUE;
} else {
++it;
}
}
return foo;
}
示例7: setGrip
void MainWindow::setGrip()
{
QLayoutIterator it = lay->iterator();
QLayoutItem *lastItem = NULL;
for (;;){
QLayoutItem *item = it.current();
if (item == NULL)
break;
lastItem = item;
if (++it == NULL)
break;
}
if (lastItem == NULL)
return;
if (lastItem->layout() && (lastItem->layout() == h_lay)){
QLayoutIterator it = h_lay->iterator();
for (;;){
QLayoutItem *item = it.current();
if (item == NULL)
break;
QWidget *w = item->widget();
if (w && (w != m_grip))
return;
if (++it == NULL)
break;
}
}
QWidget *oldWidget = NULL;
QWidget *w = lastItem->widget();
if (m_grip){
delete m_grip;
m_grip = NULL;
}
if (h_lay){
QLayoutIterator it = h_lay->iterator();
for (;;){
QLayoutItem *item = it.current();
if (item == NULL)
break;
oldWidget = item->widget();
if (oldWidget)
break;
if (++it == NULL)
break;
}
delete h_lay;
h_lay = NULL;
it = lay->iterator();
for (;;){
QLayoutItem *item = it.current();
if (item == NULL)
break;
lastItem = item;
if (++it == NULL)
break;
}
if (lastItem)
w = lastItem->widget();
}
if (oldWidget && w){
int index = lay->findWidget(w);
lay->insertWidget(index - 1, oldWidget);
}
if (w && (w->sizePolicy().verData() == QSizePolicy::Fixed) && !statusBar()->isVisible()){
w->reparent(this, QPoint());
w->reparent(main, QPoint());
h_lay = new QHBoxLayout(lay);
h_lay->addWidget(w);
h_lay->addSpacing(2);
m_grip = new QSizeGrip(main);
#ifdef WIN32
m_grip->installEventFilter(this);
#endif
m_grip->setFixedSize(m_grip->sizeHint());
h_lay->addWidget(m_grip, 0, AlignBottom);
w->show();
m_grip->show();
}
}
示例8: printLegend
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const
{
if ( !legend() || legend()->isEmpty() )
return;
QLayout *l = legend()->contentsWidget()->layout();
if ( l == 0 || !l->inherits("QwtDynGridLayout") )
return;
QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l;
uint numCols = legendLayout->columnsForWidth(rect.width());
#if QT_VERSION < 0x040000
QValueList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
#else
QList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
#endif
int index = 0;
#if QT_VERSION < 0x040000
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator) {
#else
for ( int i = 0; i < legendLayout->count(); i++ ) {
QLayoutItem *item = legendLayout->itemAt(i);
#endif
QWidget *w = item->widget();
if ( w ) {
painter->save();
painter->setClipping(true);
QwtPainter::setClipRect(painter, itemRects[index]);
printLegendItem(painter, w, itemRects[index]);
index++;
painter->restore();
}
}
}
/*!
Print the legend item into a given rectangle.
\param painter Painter
\param w Widget representing a legend item
\param rect Bounding rectangle
*/
void QwtPlot::printLegendItem(QPainter *painter,
const QWidget *w, const QRect &rect) const
{
if ( w->inherits("QwtLegendItem") ) {
QwtLegendItem *item = (QwtLegendItem *)w;
painter->setFont(item->font());
item->drawItem(painter, rect);
}
}
/*!
\brief Paint a scale into a given rectangle.
Paint the scale into a given rectangle.
\param painter Painter
\param axisId Axis
\param startDist Start border distance
\param endDist End border distance
\param baseDist Base distance
\param rect Bounding rectangle
*/
void QwtPlot::printScale(QPainter *painter,
int axisId, int startDist, int endDist, int baseDist,
const QRect &rect) const
{
if (!axisEnabled(axisId))
return;
const QwtScaleWidget *scaleWidget = axisWidget(axisId);
if ( scaleWidget->isColorBarEnabled()
&& scaleWidget->colorBarWidth() > 0) {
const QwtMetricsMap map = QwtPainter::metricsMap();
QRect r = map.layoutToScreen(rect);
r.setWidth(r.width() - 1);
r.setHeight(r.height() - 1);
scaleWidget->drawColorBar(painter, scaleWidget->colorBarRect(r));
const int off = scaleWidget->colorBarWidth() + scaleWidget->spacing();
if ( scaleWidget->scaleDraw()->orientation() == Qt::Horizontal )
baseDist += map.screenToLayoutY(off);
else
baseDist += map.screenToLayoutX(off);
}
//.........这里部分代码省略.........
示例9: insert
/*!
Insert a new item for a plot item
\param plotItem Plot item
\param legendItem New legend item
\note The parent of item will be changed to QwtLegend::contentsWidget()
*/
void QwtLegend::insert(const QwtPlotItem *plotItem, QWidget *legendItem)
{
if ( legendItem == NULL || plotItem == NULL )
return;
QWidget *contentsWidget = d_data->view->contentsWidget;
if ( legendItem->parent() != contentsWidget )
{
#if QT_VERSION >= 0x040000
legendItem->setParent(contentsWidget);
#else
legendItem->reparent(contentsWidget, QPoint(0, 0));
#endif
}
legendItem->show();
d_data->map.insert(plotItem, legendItem);
layoutContents();
if ( contentsWidget->layout() )
{
#if QT_VERSION >= 0x040000
contentsWidget->layout()->addWidget(legendItem);
#endif
// set tab focus chain
QWidget *w = NULL;
#if QT_VERSION < 0x040000
QLayoutIterator layoutIterator =
contentsWidget->layout()->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator)
{
#else
for (int i = 0; i < contentsWidget->layout()->count(); i++)
{
QLayoutItem *item = contentsWidget->layout()->itemAt(i);
#endif
if ( w && item->widget() )
{
QWidget::setTabOrder(w, item->widget());
w = item->widget();
}
}
}
if ( parentWidget() && parentWidget()->layout() == NULL )
{
/*
updateGeometry() doesn't post LayoutRequest in certain
situations, like when we are hidden. But we want the
parent widget notified, so it can show/hide the legend
depending on its items.
*/
#if QT_VERSION < 0x040000
QApplication::postEvent(parentWidget(),
new QEvent(QEvent::LayoutHint));
#else
QApplication::postEvent(parentWidget(),
new QEvent(QEvent::LayoutRequest));
#endif
}
}
QWidget *QwtLegend::find(const QwtPlotItem *plotItem) const
{
return d_data->map.find(plotItem);
}
QwtPlotItem *QwtLegend::find(const QWidget *legendItem) const
{
return d_data->map.find(legendItem);
}
//! Find the corresponding item for a plotItem and remove it from the item list.
void QwtLegend::remove(const QwtPlotItem *plotItem)
{
QWidget *legendItem = d_data->map.find(plotItem);
d_data->map.remove(legendItem);
delete legendItem;
}
示例10: renderLegend
void QwtPolarPlot::renderLegend( QPainter *painter, const QRect &rect ) const
{
#if 1
// Shift this code into QwtLegend, so that Qwt/QwtPolar can share it
#endif
if ( !legend() || legend()->isEmpty() )
return;
QLayout *l = legend()->contentsWidget()->layout();
if ( l == 0 || !l->inherits( "QwtDynGridLayout" ) )
return;
QwtDynGridLayout *legendLayout = ( QwtDynGridLayout * )l;
uint numCols = legendLayout->columnsForWidth( rect.width() );
#if QT_VERSION < 0x040000
QValueList<QRect> itemRects =
legendLayout->layoutItems( rect, numCols );
#else
QList<QRect> itemRects =
legendLayout->layoutItems( rect, numCols );
#endif
int index = 0;
#if QT_VERSION < 0x040000
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator )
{
#else
for ( int i = 0; i < legendLayout->count(); i++ )
{
QLayoutItem *item = legendLayout->itemAt( i );
#endif
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipping( true );
QwtPainter::setClipRect( painter, itemRects[index] );
renderLegendItem( painter, w, itemRects[index] );
index++;
painter->restore();
}
}
}
/*!
Render the legend item into a given rectangle.
\param painter Painter
\param w Widget representing a legend item
\param rect Bounding rectangle
*/
void QwtPolarPlot::renderLegendItem( QPainter *painter,
const QWidget *w, const QRect &rect ) const
{
#if 1
// Shift this code into QwtLegend, so that Qwt/QwtPolar can share it
#endif
if ( w->inherits( "QwtLegendItem" ) )
{
QwtLegendItem *item = ( QwtLegendItem * )w;
painter->setFont( item->font() );
item->drawItem( painter, rect );
}
}
示例11: printLegend
void QwtPlot::printLegend(QPainter *painter, const QRect &rect) const
{
if ( !legend() || legend()->isEmpty() )
return;
QLayout *l = legend()->contentsWidget()->layout();
if ( l == 0 || !l->inherits("QwtDynGridLayout") )
return;
QwtDynGridLayout *legendLayout = (QwtDynGridLayout *)l;
uint numCols = legendLayout->columnsForWidth(rect.width());
#if QT_VERSION < 0x040000
QValueList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
#else
QList<QRect> itemRects =
legendLayout->layoutItems(rect, numCols);
#endif
int index = 0;
#if QT_VERSION < 0x040000
QLayoutIterator layoutIterator = legendLayout->iterator();
for ( QLayoutItem *item = layoutIterator.current();
item != 0; item = ++layoutIterator)
{
#else
for ( int i = 0; i < legendLayout->count(); i++ )
{
QLayoutItem *item = legendLayout->itemAt(i);
#endif
QWidget *w = item->widget();
if ( w )
{
painter->save();
painter->setClipping(true);
QwtPainter::setClipRect(painter, itemRects[index]);
printLegendItem(painter, w, itemRects[index]);
index++;
painter->restore();
}
}
}
/*!
Print the legend item into a given rectangle.
\param painter Painter
\param w Widget representing a legend item
\param rect Bounding rectangle
*/
void QwtPlot::printLegendItem(QPainter *painter,
const QWidget *w, const QRect &rect) const
{
if ( w->inherits("QwtLegendItem") )
{
QwtLegendItem *item = (QwtLegendItem *)w;
painter->setFont(item->font());
item->drawItem(painter, rect);
}
}
/*!
\brief Paint a scale into a given rectangle.
Paint the scale into a given rectangle.
\param painter Painter
\param axisId Axis
\param startDist Start border distance
\param endDist End border distance
\param baseDist Base distance
\param rect Bounding rectangle
*/
void QwtPlot::printScale(QPainter *painter,
int axisId, int startDist, int endDist, int baseDist,
const QRect &rect) const
{
if (!axisEnabled(axisId))
return;
QwtScaleDraw::Alignment align;
int x, y, w;
switch(axisId)
{
case yLeft:
{
x = rect.right() - baseDist + 1;
y = rect.y() + startDist;
w = rect.height() - startDist - endDist;
align = QwtScaleDraw::LeftScale;
break;
}
case yRight:
//.........这里部分代码省略.........
示例12: eventFilter
bool QLayout::eventFilter( QObject *o, QEvent *e )
{
if ( !enabled )
return FALSE; // nothing we can do, should do or want to do
if ( o == this && e->type() == QEvent::ChildRemoved ) {
//we cannot implement childEvent() or event() because of
//###binary compatibility.
QChildEvent *c = (QChildEvent*)e;
QLayoutIterator it = iterator();
QLayoutItem *item;
while ( (item = it.current() ) ) {
if ( item == (QLayout*)c->child() ) {
it.takeCurrent();
invalidate();
return FALSE;
}
++it;
}
return FALSE;
}
if ( !o->isWidgetType() )
return FALSE;
switch ( e->type() ) {
case QEvent::Resize:
if ( activated ) {
QResizeEvent *r = (QResizeEvent*)e;
int mbh = 0;
#ifndef QT_NO_MENUBAR
if ( menubar && !menubar->isHidden() && !menubar->isTopLevel() )
mbh = menubar->heightForWidth( r->size().width() );
#endif
int b = marginImpl ? 0 : outsideBorder;
setGeometry( QRect( b, mbh + b, r->size().width() - 2*b,
r->size().height() - mbh - 2*b ) );
} else {
activate();
}
break;
case QEvent::ChildRemoved: {
QChildEvent *c = (QChildEvent*)e;
if ( c->child()->isWidgetType() ) {
QWidget *w = (QWidget*)c->child();
#ifndef QT_NO_MENUBAR
if ( w == menubar )
menubar = 0;
#endif
if ( removeWidget( this, w ) ) {
QEvent *lh = new QEvent( QEvent::LayoutHint );
QApplication::postEvent( o, lh );
}
}
break;
}
case QEvent::ChildInserted:
if ( topLevel && autoNewChild ) {
QChildEvent *c = (QChildEvent*)e;
if ( c->child()->isWidgetType() ) {
QWidget *w = (QWidget*)c->child();
if ( !w->isTopLevel() ) {
#ifndef QT_NO_MENUBAR
if ( w->inherits( "QMenuBar" ) && ( !w->parent() || !w->parent()->inherits( "QToolBar" ) ) )
menubar = (QMenuBar*)w;
else
#endif
addItem( new QWidgetItem( w ) );
QEvent *lh = new QEvent( QEvent::LayoutHint );
QApplication::postEvent( o, lh );
}
}
}
break;
case QEvent::LayoutHint:
activate();
break;
default:
break;
}
return QObject::eventFilter( o, e );
}