当前位置: 首页>>代码示例>>C++>>正文


C++ QWidget::children方法代码示例

本文整理汇总了C++中QWidget::children方法的典型用法代码示例。如果您正苦于以下问题:C++ QWidget::children方法的具体用法?C++ QWidget::children怎么用?C++ QWidget::children使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QWidget的用法示例。


在下文中一共展示了QWidget::children方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: it

static QWidget * find_child( QWidget * tlw, QPoint & p )
{
    QWidget * w = tlw;

    p = w->mapFromGlobal( p );
    bool done = FALSE;
    while ( !done ) {
	done = TRUE;
	if ( ((QExtraWidget*)w)->extraData() &&
	     ((QExtraWidget*)w)->extraData()->xDndProxy != 0 )
	    break; // stop searching for widgets under the mouse cursor if found widget is a proxy.
	if ( w->children() ) {
	    QObjectListIt it( *w->children() );
	    it.toLast();
	    QObject * o;
	    while( (o=it.current()) ) {
		--it;
		if ( o->isWidgetType() &&
		     ((QWidget*)o)->isVisible() &&
		     ((QWidget*)o)->geometry().contains( p ) &&
		     !((QWidget*)o)->isTopLevel()) {
		    w = (QWidget *)o;
		    done = FALSE;
		    p = w->mapFromParent( p );
		    break;
		}
	    }
	}
    }
    return w;
}
开发者ID:AliYousuf,项目名称:abanq-port,代码行数:31,代码来源:qdnd_x11.cpp

示例2: it

static QWidget * find_child( QWidget * tlw, QPoint & p )
{
    QWidget * w = tlw;

    p = w->mapFromGlobal( p );
    bool done = FALSE;
    while ( !done ) {
	done = TRUE;
	if ( w->children() ) {
	    QObjectListIt it( *w->children() );
	    it.toLast();
	    QObject * o;
	    while( (o=it.current()) ) {
		--it;
		if ( o->isWidgetType() &&
		     ((QWidget*)o)->isVisible() &&
		     ((QWidget*)o)->geometry().contains( p ) ) {
		    w = (QWidget *)o;
		    done = FALSE;
		    p = w->mapFromParent( p );
		    break;
		}
	    }
	}
    }
    return w;
}
开发者ID:kthxbyte,项目名称:Qt1.45-Linaro,代码行数:27,代码来源:qdnd_x11.cpp

示例3: logic_error

Support::ToolSelector* GraphicsView::
        toolSelector(int index, Tools::Commands::CommandInvoker* state)
{
    while (index >= layout_widget_->layout()->count())
    {
        EXCEPTION_ASSERT( state );

        QWidget* parent = new QWidget();
        parent->setLayout(new QVBoxLayout());
        parent->layout()->setMargin(0);

        Support::ToolSelector* tool_selector = new Support::ToolSelector( state, parent );
        tool_selector->setParent( parent );

        layout_widget_->layout()->addWidget( parent );
    }

    QWidget* parent = layout_widget_->layout()->itemAt(index)->widget();
    for (int i = 0; i<parent->children().count(); ++i)
    {
        Support::ToolSelector* t = dynamic_cast<Support::ToolSelector*>( parent->children().at(i) );
        if (t)
            return t;
    }

    throw std::logic_error("Support::ToolSelector* GraphicsView::toolSelector");
}
开发者ID:aveminus,项目名称:freq,代码行数:27,代码来源:graphicsview.cpp

示例4: main

int main(int argc,char **argv)
{
    QApplication application(argc,argv);

    QWidget container;
    QVBoxLayout *layout = new QVBoxLayout(&container);

    QPushButton *MyButton = new QPushButton("Press Me");
    QLabel *MyLabel=new QLabel("I am a  label");


    layout->addWidget(MyButton);

    layout->addWidget(MyLabel);

    container.show();

    qDebug() << "Layout Children:" << layout->children().count();
    qDebug() << "Container Children:" << container.children().count();



    QDataStream stream();


    return application.exec();

}
开发者ID:davidlibbyFIT,项目名称:Libby,代码行数:28,代码来源:main.cpp

示例5: resizeIcons

void PaletteTreeWidgets::resizeIcons()
{
	if (mParentPalette->iconsView() && mParentPalette->itemsCountInARow() > 1) {
		const int iconSize = 48;
		const int widgetSize = this->size().width() - (iconSize << 1);
		const int itemsCount = maxItemsCountInARow();
		const int newSize = (widgetSize < itemsCount * iconSize)
				? (widgetSize / itemsCount) : iconSize;
		for (int i = 0; i < mEditorTree->topLevelItemCount(); i++) {
			for (int j = 0; j < mEditorTree->topLevelItem(i)->childCount(); j++) {
				QWidget *field = mEditorTree->itemWidget(mEditorTree->topLevelItem(i)->child(j), 0);
				if (!field) {
					break;
				}

				for (QObject *child : field->children()) {
					DraggableElement *element = dynamic_cast<DraggableElement*>(child);
					if (element) {
						element->setIconSize(newSize);
					}
				}
			}
		}
	}
}
开发者ID:qreal,项目名称:qreal,代码行数:25,代码来源:paletteTreeWidgets.cpp

示例6: eventFilter

bool SGMainWindowEvent::eventFilter(QObject* object, QEvent* evt) {
	QWidget* focusWidget = QApplication::focusWidget();
	if (focusWidget == NULL) return true;
	if (m_focusWidgetName == focusWidget->objectName().toStdString().c_str()) return QObject::eventFilter(object, evt);

	QObjectList objList = focusWidget->children();
	bool glWidgetExists = false;
	for (int i = 0; i < objList.length(); i++) {
		QWidget* widget = (QWidget*)objList[i];
		QObjectList objList2 = widget->children();
		for (int j = 0; j < objList2.length(); j++) {
			QWidget* widget2 = (QWidget*)objList2[j];
			if (strcmp(widget2->metaObject()->className(), "QmayaGLWidget") == 0) {
				if (m_beforeWidget != NULL) {
					m_beforeWidget->releaseKeyboard();
					m_beforeWidget->removeEventFilter(toolEvent);
				}
				widget2->installEventFilter(toolEvent);
				widget2->grabKeyboard();

				m_beforeWidget = widget2;

				m_focusWidgetName = focusWidget->objectName().toStdString().c_str();
				glWidgetExists = true;

				SGKey::initializeKeys();
				SGMouse::initializeButtons();
				break;
			}
		}
		if (glWidgetExists)break;
	}

	if (!glWidgetExists) {
		if (m_beforeWidget != NULL) {
			m_beforeWidget->releaseKeyboard();
			m_beforeWidget->removeEventFilter(toolEvent);
		}
		m_focusWidgetName = focusWidget->objectName().toStdString().c_str();
	}

	return QObject::eventFilter(object, evt);
}
开发者ID:jonntd,项目名称:mayadev-1,代码行数:43,代码来源:SGMainWindowEvent.cpp

示例7: onHmidataRuning

void MainWindow::onHmidataRuning(bool val){
    QWidget *tab = tabWidget->widget(4);//test widget
    QObjectList list = tab->children();
    foreach(QObject *widget,list){
        if(widget->isWidgetType()){
            ((QWidget *)widget)->setDisabled(val);
        }
    }
    qMdPushButton_11->setDisabled(val);//shazui updown
}
开发者ID:httpftpli,项目名称:mdimh,代码行数:10,代码来源:mainwindow.cpp

示例8: outputSizeReport

void QRWindow::outputSizeReport() {
   if (!m_isDebugMode) return;
   printf("\n\n=============================================[Size Report]===\n");
   stack <QList<QWidget *> > stackWidgets;
   
   QList<QWidget *> listWidgets; listWidgets.append(this);
   stackWidgets.push(listWidgets);
    
   while (!stackWidgets.empty()) {
      QList<QWidget *> widgets = stackWidgets.top(); stackWidgets.pop();
      bool new_level = false;
      while (widgets.size() && !new_level) {
         QWidget *widget = widgets.takeFirst();
         if (QROSE::getName(widget) != "") {
            printf("%*c%s [w:%d,h:%d,x:%d,y:%d]\n", (int) (3*stackWidgets.size()), ' ', 
                QROSE::getName(widget).c_str(), 
                widget->width(), widget->height(),
                widget->x(), widget->y());            
         }
         QList<QWidget *> childrenW;
         int n = widget->children().size();
         for (int i = 0; i < n; i++) {
             QObject *obj = widget->children().at(i);
             if (obj->isWidgetType()) {
                childrenW.append((QWidget *)obj);
             }
         }
         
         if (childrenW.size() != 0) {
            new_level = true;
            stackWidgets.push(widgets);
            stackWidgets.push(childrenW);
         }       
      }
   }
   printf("=============================================================\n");
   
}
开发者ID:Federico2014,项目名称:edg4x-rose,代码行数:38,代码来源:QRWindow.C

示例9: setInMotion

void DayWidget::setInMotion(bool value)
{
	if (m_inMotion == value)
		return;

	m_inMotion = value;

	if (m_inMotion) { // record the above widget and put itself in the stack top
		QWidget *parent = parentWidget();
		m_aboveWidget = 0;
		for (int index = parent->children().indexOf(this) + 1; index < parent->children().count(); index++) {
			QWidget *widget = qobject_cast<QWidget*>(parent->children()[index]);
			if (widget) {
				m_aboveWidget = widget;
				break;
			}
		}
		raise();
	} else { // restore the widget in the stack
		if (m_aboveWidget)
			stackUnder(m_aboveWidget);
	}
}
开发者ID:NyFanomezana,项目名称:freemedforms,代码行数:23,代码来源:day_widget.cpp

示例10: mousePressEvent

	void UiManager::mousePressEvent(QMouseEvent *event)
	{
		QWidget *pressedWidget = NULL;
	
		// get the clicked item through the view (respects view and item transformations)
		QGraphicsItem* itemAt = mWidgetView->itemAt(event->pos());
		if ((itemAt) && (itemAt->isWidget()))
		{
			QGraphicsProxyWidget *proxyWidget = qgraphicsitem_cast<QGraphicsProxyWidget *>(itemAt);
			if (proxyWidget)
			{
				QWidget *embeddedWidget = proxyWidget->widget();
	
				// if the widget has children, use them, otherwise use the widget directly
				if (embeddedWidget->children().size() > 0)
				{
					QPoint widgetPoint = proxyWidget->mapFromScene(mWidgetView->mapToScene(event->pos())).toPoint();
					pressedWidget = embeddedWidget->childAt(widgetPoint);
				}
				else
				{
					pressedWidget = embeddedWidget;
				}
			}
		}
	
		// if there was a focused widget and there is none or a different one now, defocus
		if (mFocusedWidget && (!pressedWidget || pressedWidget != mFocusedWidget))
		{
			QEvent foe(QEvent::FocusOut);
			QApplication::sendEvent(mFocusedWidget, &foe);
			mFocusedWidget = NULL;
			mTopLevelWidget->setFocus();
		}
	
		// set the new focus
		if (pressedWidget)
		{
			QEvent fie(QEvent::FocusIn);
			QApplication::sendEvent(pressedWidget, &fie);
			pressedWidget->setFocus(Qt::MouseFocusReason);
			mFocusedWidget = pressedWidget;
		}
	
		QApplication::sendEvent(mWidgetView->viewport(), event);
	}
开发者ID:advancingu,项目名称:Cutexture,代码行数:46,代码来源:UiManager.cpp

示例11: maxItemsCountInARow

int PaletteTreeWidgets::maxItemsCountInARow() const
{
	int max = 0;
	for (int i = 0; i < mEditorTree->topLevelItemCount(); i++) {
		for (int j = 0; j < mEditorTree->topLevelItem(i)->childCount(); j++) {
			QWidget *field = mEditorTree->itemWidget(mEditorTree->topLevelItem(i)->child(j), 0);
			if (!field) {
				break;
			}

			int itemsCount = field->children().count();
			if (itemsCount > max) {
				max = itemsCount;
			}
		}
	}
	return max;
}
开发者ID:qreal,项目名称:qreal,代码行数:18,代码来源:paletteTreeWidgets.cpp

示例12: serialize

void UISerializationUtil::serialize( TamyEditor* rootWidget, MainEditorPanel* editorsPanel, bool save )
{
   // create the settings instance
   QSettings* uiSettings = new QSettings( "Coversion", "TamyEditor" );

   // serialize the editors manager
   {
      if ( save )
      {
         editorsPanel->saveLayout( *uiSettings );
      }
      else
      {
         editorsPanel->loadLayout( *uiSettings );
      }
   }

   // serialize the hierarchy of widgets
   {
      std::list< QWidget* >   widgetsQueue;
      widgetsQueue.push_back( rootWidget );

      while( !widgetsQueue.empty() )
      {
         QWidget* currWidget = widgetsQueue.front();
         widgetsQueue.pop_front();

         serializeWidgetSettings( *currWidget, *uiSettings, save );

         // analyze the widget's children
         const QObjectList& children = currWidget->children();
         foreach( QObject* obj, children )
         {
            QWidget* childWidget = dynamic_cast< QWidget* >( obj );
            if ( childWidget )
            {
               widgetsQueue.push_back( childWidget );
            }
         }
      }
   }
开发者ID:chenwenbin928,项目名称:tamy,代码行数:41,代码来源:UISerializationUtil.cpp

示例13: showLineNumbers

void Note::showLineNumbers(bool show)
{
	if (d_line_number_enabled == show)
		return;

	d_line_number_enabled = show;

	for (int i = 0; i < d_tab_widget->count(); i++){
		QWidget *w = d_tab_widget->widget(i);
		if (!w)
			continue;

		QObjectList lst = w->children();
		foreach (QObject *obj, lst){
			LineNumberDisplay *display = qobject_cast<LineNumberDisplay *>(obj);
			if (display){
				display->setVisible(show);
				break;
			}
		}
	}
开发者ID:BackupTheBerlios,项目名称:qtiplot-svn,代码行数:21,代码来源:Note.cpp

示例14: setDefaultFontSize

void WidgetSizeHelper::setDefaultFontSize(QWidget* pWidget) {

    // we get all of pWidget's children
    QObjectList children = pWidget->children();

    // for each child
    for ( int i = 0; i < children.length(); i++ ) {

        /*
         * we change its font size if it is of one of those types
         *
         *  - QLabel
         *  - QLineEdit
         *  - QRadioButton
         *  - QGroupBox
         *  - QCheckBox
         *  - QStatusBar
         */
        QWidget* pChild = static_cast<QWidget*> ( children.at(i) );

        if (  qobject_cast<QLabel*>(pChild) != NULL         ||
              qobject_cast<QLineEdit*>(pChild) != NULL      ||
              qobject_cast<QRadioButton*>(pChild) != NULL   ||
              qobject_cast<QGroupBox*>(pChild) != NULL      ||
              qobject_cast<QCheckBox*>(pChild) != NULL      ||
              qobject_cast<QStatusBar*>(pChild) != NULL )
        {
            QFont lFont = pChild->font();
            lFont.setPointSize(Constants::MAC_FONT_SIZE);
            pChild->setFont(lFont);
        }

        // and scan it, if it has children
        if (  ! pChild->children().isEmpty() ) {

            setDefaultFontSize( pChild );
        }
    }
}
开发者ID:ViktorNova,项目名称:Qrest,代码行数:39,代码来源:widgetsizehelper.cpp

示例15: buddyString

static QString buddyString(const QWidget *widget)
{
    if (!widget)
        return QString();
    QWidget *parent = widget->parentWidget();
    if (!parent)
        return QString();
#ifndef QT_NO_SHORTCUT
    QObjectList ol = parent->children();
    for (int i = 0; i < ol.size(); ++i) {
        QLabel *label = qobject_cast<QLabel*>(ol.at(i));
        if (label && label->buddy() == widget)
            return label->text();
    }
#endif

#ifndef QT_NO_GROUPBOX
    QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent);
    if (groupbox)
        return groupbox->title();
#endif

    return QString();
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:24,代码来源:qaccessiblewidget.cpp


注:本文中的QWidget::children方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。