本文整理汇总了C++中QObjectList::count方法的典型用法代码示例。如果您正苦于以下问题:C++ QObjectList::count方法的具体用法?C++ QObjectList::count怎么用?C++ QObjectList::count使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QObjectList
的用法示例。
在下文中一共展示了QObjectList::count方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: grips
void tst_QColumnView::grips()
{
QColumnView view;
QDirModel model;
view.setModel(&model);
QCOMPARE(view.resizeGripsVisible(), true);
view.setResizeGripsVisible(true);
QCOMPARE(view.resizeGripsVisible(), true);
{
const QObjectList list = view.viewport()->children();
for (int i = 0 ; i < list.count(); ++i) {
if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i)))
QVERIFY(view->cornerWidget() != 0);
}
}
view.setResizeGripsVisible(false);
QCOMPARE(view.resizeGripsVisible(), false);
{
const QObjectList list = view.viewport()->children();
for (int i = 0 ; i < list.count(); ++i) {
if (QAbstractItemView *view = qobject_cast<QAbstractItemView*>(list.at(i))) {
if (view->isVisible())
QVERIFY(view->cornerWidget() == 0);
}
}
}
view.setResizeGripsVisible(true);
QCOMPARE(view.resizeGripsVisible(), true);
}
示例2: setUpLayout
void QMainWindow::setUpLayout()
{
d->timer->stop();
delete d->tll;
d->tll = new QBoxLayout( this, QBoxLayout::Down );
if ( !d->mb ) {
// slightly evil hack here. reconsider this after 1.40.
QObjectList * l
= ((QObject*)this)->queryList( "QMenuBar", 0, FALSE, FALSE );
if ( l && l->count() )
d->mb = menuBar();
delete l;
}
if ( d->mb && !d->mb->testWFlags( WState_DoHide ) )
d->tll->setMenuBar( d->mb );
if ( style() == WindowsStyle )
d->tll->addSpacing( 1 );
addToolBarToLayout( d->top, d->tll,
QBoxLayout::LeftToRight, QBoxLayout::Down, FALSE,
d->justify, style() );
QBoxLayout * mwl = new QBoxLayout( QBoxLayout::LeftToRight );
d->tll->addLayout( mwl, 1 );
addToolBarToLayout( d->left, mwl,
QBoxLayout::Down, QBoxLayout::LeftToRight, FALSE,
d->justify, style() );
if ( centralWidget() && !centralWidget()->testWFlags( WState_DoHide ) )
mwl->addWidget( centralWidget(), 1 );
else
mwl->addStretch( 1 );
addToolBarToLayout( d->right, mwl,
QBoxLayout::Down, QBoxLayout::LeftToRight, FALSE,
d->justify, style() );
addToolBarToLayout( d->bottom, d->tll,
QBoxLayout::LeftToRight, QBoxLayout::Up, TRUE,
d->justify, style() );
if ( !d->sb ) {
// as above.
QObjectList * l
= ((QObject*)this)->queryList( "QStatusBar", 0, FALSE, FALSE );
if ( l && l->count() )
d->sb = statusBar();
delete l;
}
if ( d->sb && !d->sb->testWFlags( WState_DoHide ) )
d->tll->addWidget( d->sb, 0 );
//debug( "act %d, %d", x(), y() );
d->tll->activate();
}
示例3: parentHeightChanged
void Map::parentHeightChanged(float parentHeight)
{
const float padding = 10; // Padding of at least 10 on all sides.
parentHeight = parentHeight - padding*2;
const float cellWidth = m_mapWidth / m_cols;
const float cellHeight = parentHeight / m_rows;
float oldCellSize = m_cellSize;
m_cellSize = std::min(cellWidth, cellHeight);
m_mapArea->setPreferredSize(m_cellSize * m_cols, m_cellSize * m_rows);
QObjectList list = m_mapArea->children();
if (m_rows * m_cols + 1 != list.count()) { qDebug("Uhoh: List size not correct!"); }
int i=0;
for (int y=0; y<m_rows; y++) {
for (int x=0; x<m_cols; x++) {
ImageView *cell = qobject_cast<ImageView*>(list[i]);
if (cell) {
cell->setPreferredSize(m_cellSize, m_cellSize);
AbsoluteLayoutProperties *properties = static_cast<AbsoluteLayoutProperties*>(cell->layoutProperties());
properties->setPositionX(x * m_cellSize);
properties->setPositionY(y * m_cellSize);
}
i++;
}
}
Container *robot = qobject_cast<Container*>(list[i]);
if (robot) {
robot->setPreferredSize(m_cellSize, m_cellSize);
AbsoluteLayoutProperties *properties = static_cast<AbsoluteLayoutProperties*>(robot->layoutProperties());
properties->setPositionX(properties->positionX() * m_cellSize / oldCellSize);
properties->setPositionY(properties->positionY() * m_cellSize / oldCellSize);
}
}
示例4: loadStaticPlugins
void QGeoSatelliteInfoSourcePrivate::loadStaticPlugins(QHash<QString, QGeoPositionInfoSourceFactory *> &plugins)
{
#if !defined QT_NO_DEBUG
const bool showDebug = qgetenv("QT_DEBUG_PLUGINS").toInt() > 0;
#endif
QObjectList staticPlugins = QPluginLoader::staticInstances();
for (int i = 0; i < staticPlugins.count(); ++i) {
QGeoPositionInfoSourceFactory *f =
qobject_cast<QGeoPositionInfoSourceFactory*>(staticPlugins.at(i));
if (f) {
QString name = f->sourceName();
#if !defined QT_NO_DEBUG
if (showDebug)
qDebug("Static: found a service provider plugin with name %s", qPrintable(name));
#endif
if (!name.isEmpty()) {
plugins.insertMulti(name, f);
}
}
}
}
示例5: moveGrip
void tst_QColumnView::moveGrip()
{
QFETCH(bool, reverse);
if (reverse)
qApp->setLayoutDirection(Qt::RightToLeft);
ColumnView view;
TreeModel model;
view.setModel(&model);
QModelIndex home = model.thirdLevel();
view.setCurrentIndex(home);
view.resize(640, 200);
view.show();
QTest::qWait(ANIMATION_DELAY);
int columnNum = view.createdColumns.count() - 2;
QVERIFY(columnNum >= 0);
QObjectList list = view.createdColumns[columnNum]->children();
QColumnViewGrip *grip = 0;
for (int i = 0; i < list.count(); ++i) {
if ((grip = qobject_cast<QColumnViewGrip *>(list[i]))) {
break;
}
}
if (!grip)
return;
QAbstractItemView *column = qobject_cast<QAbstractItemView *>(grip->parent());
int oldX = column->width();
QCOMPARE(view.columnWidths()[columnNum], oldX);
grip->moveGrip(10);
QCOMPARE(view.columnWidths()[columnNum], (oldX + (reverse ? -10 : 10)));
}
示例6: QCOMPARE
void tst_Q3ActionGroup::dropDownDeleted()
{
Q3MainWindow mw;
Q3ToolBar *tb = new Q3ToolBar(&mw);
Q3ActionGroup *actGroup = new Q3ActionGroup(&mw);
actGroup->setUsesDropDown(TRUE);
Q3Action *actOne = new Q3Action(actGroup);
actOne->setText("test one");
Q3Action *actTwo = new Q3Action(actGroup);
actTwo->setText("test two");
Q3Action *actThree= new Q3Action(actGroup);
actThree->setText("test three");
actGroup->addTo(tb);
QObjectList comboList = tb->queryList("QComboBox");
QCOMPARE(comboList.count(), 1);
QCOMPARE((int)((QComboBox*)comboList[0])->count(), 3);
delete actOne;
QCOMPARE((int)((QComboBox*)comboList[0])->count(), 2);
delete actTwo;
QCOMPARE((int)((QComboBox*)comboList[0])->count(), 1);
delete actThree;
QCOMPARE((int)((QComboBox*)comboList[0])->count(), 0);
delete actGroup;
}
示例7:
QObject *Item3dPrivate::resources_at(QDeclarativeListProperty<QObject> *prop, int index)
{
QObjectList children = prop->object->children();
if (index < children.count())
return children.at(index);
else
return 0;
}
示例8: connectSlotsByName
void QMetaUtilities::connectSlotsByName(QObject * source, QObject * target)
{
if (!source || !target) return;
const QMetaObject * source_mo = source->metaObject();
const QMetaObject * target_mo = target->metaObject();
Q_ASSERT(source_mo);
Q_ASSERT(target_mo);
// find source's children
// and add source itself to the list, so we can autoconnect its signals too
const QObjectList list = source->findChildren<QObject *>(QString()) << source;
for (int i = 0; i < target_mo->methodCount(); ++i) {
const char *slot = target_mo->method(i).signature();
Q_ASSERT(slot);
if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_')
continue;
bool foundIt = false;
for(int j = 0; j < list.count(); ++j) {
const QObject *co = list.at(j);
const QMetaObject *smo = co->metaObject();
QByteArray objName = co->objectName().toAscii();
int len = objName.length();
if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
continue;
int sigIndex = smo->indexOfSignal(slot + len + 4);
if (sigIndex < 0) { // search for compatible signals
int slotlen = qstrlen(slot + len + 4) - 1;
for (int k = 0; k < co->metaObject()->methodCount(); ++k) {
QMetaMethod method = smo->method(k);
if (method.methodType() != QMetaMethod::Signal)
continue;
if (!qstrncmp(method.signature(), slot + len + 4, slotlen)) {
sigIndex = k;
break;
}
}
}
if (sigIndex < 0)
continue;
if (QMetaObject::connect(co, sigIndex, target, i)) {
foundIt = true;
break;
}
}
if (foundIt) {
// we found our slot, now skip all overloads
while (target_mo->method(i + 1).attributes() & QMetaMethod::Cloned)
++i;
} else if (!(target_mo->method(i).attributes() & QMetaMethod::Cloned)) {
qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
}
}
}
示例9:
EventLoop::~EventLoop() {
QMainWindow * wnd = StaticUtils::findMainWindow();
if (wnd != NULL) {
wnd->removeEventFilter(this);
QObjectList childs = wnd->children();
for (int i=0;i<childs.count();i++) {
if (childs.at(i)->inherits("QWidget")) childs.at(i)->removeEventFilter(this);
}
}
}
示例10: connectObjectSlotsByName
void mafObjectBase::connectObjectSlotsByName(QObject *signal_object) {
const QMetaObject *mo = this->metaObject();
Q_ASSERT(mo);
const QObjectList list = qFindChildren<QObject *>(signal_object, QString());
for (int i = 0; i < mo->methodCount(); ++i) {
QMetaMethod method_slot = mo->method(i);
if (method_slot.methodType() != QMetaMethod::Slot)
continue;
const char *slot = mo->method(i).signature();
if (slot[0] != 'o' || slot[1] != 'n' || slot[2] != '_')
continue;
bool foundIt = false;
for(int j = 0; j < list.count(); ++j) {
const QObject *co = list.at(j);
QByteArray objName = co->objectName().toAscii();
int len = objName.length();
if (!len || qstrncmp(slot + 3, objName.data(), len) || slot[len+3] != '_')
continue;
int sigIndex = -1; //co->metaObject()->signalIndex(slot + len + 4);
const QMetaObject *smo = co->metaObject();
if (sigIndex < 0) { // search for compatible signals
int slotlen = qstrlen(slot + len + 4) - 1;
for (int k = 0; k < co->metaObject()->methodCount(); ++k) {
QMetaMethod method = smo->method(k);
if (method.methodType() != QMetaMethod::Signal)
continue;
if (!qstrncmp(method.signature(), slot + len + 4, slotlen)) {
const char *signal = method.signature();
QString event_sig = SIGNAL_SIGNATURE;
event_sig.append(signal);
QString observer_sig = CALLBACK_SIGNATURE;
observer_sig.append(slot);
if(connect(co, event_sig.toAscii(), this, observer_sig.toAscii())) {
qDebug() << mafTr("CONNECTED slot %1 with signal %2").arg(slot, signal);
foundIt = true;
break;
} else {
qWarning() << mafTr("Cannot connect slot %1 with signal %2").arg(slot, signal);
}
}
}
}
}
if (foundIt) {
// we found our slot, now skip all overloads
while (mo->method(i + 1).attributes() & QMetaMethod::Cloned)
++i;
} else if (!(mo->method(i).attributes() & QMetaMethod::Cloned)) {
qWarning("QMetaObject::connectSlotsByName: No matching signal for %s", slot);
}
}
}
示例11: buildStatesList
void QQmlQtQuick2DebugStatesDelegate::buildStatesList(QObject *obj)
{
if (QQuickState *state = qobject_cast<QQuickState *>(obj)) {
m_allStates.append(state);
}
QObjectList children = obj->children();
for (int ii = 0; ii < children.count(); ++ii) {
buildStatesList(children.at(ii));
}
}
示例12: updateWindowObjects
void QDeclarativeWebViewPrivate::updateWindowObjects()
{
if (!q->isComponentCompletePublic() || !q->page())
return;
for (int i = 0; i < windowObjects.count(); ++i) {
QObject* object = windowObjects.at(i);
QDeclarativeWebViewAttached* attached = static_cast<QDeclarativeWebViewAttached *>(qmlAttachedPropertiesObject<QDeclarativeWebView>(object));
if (attached && !attached->windowObjectName().isEmpty())
q->page()->mainFrame()->addToJavaScriptWindowObject(attached->windowObjectName(), object);
}
}
示例13: installFiliter
void AutoHideWidget::installFiliter(QObject *o){
QObjectList children = o->children();
for(int n=0;n < children.count();n++){
if(children[n]->isWidgetType()){
qDebug()<<"AutoHideWidget::installFilter:child name:"<<children[n]->objectName();
QWidget *w = static_cast<QWidget*>(children[n]);
w->setMouseTracking(true);
w->installEventFilter(this);
installFiliter(children[n]);
}
}
}
示例14: childWidgets
/*! \reimp */
QVector<QPair<QAccessibleInterface*, QAccessible::Relation> >
QAccessibleWidget::relations(QAccessible::Relation match /*= QAccessible::AllRelations*/) const
{
QVector<QPair<QAccessibleInterface*, QAccessible::Relation> > rels;
if (match & QAccessible::Label) {
const QAccessible::Relation rel = QAccessible::Label;
if (QWidget *parent = widget()->parentWidget()) {
#ifndef QT_NO_SHORTCUT
// first check for all siblings that are labels to us
// ideally we would go through all objects and check, but that
// will be too expensive
const QList<QWidget*> kids = childWidgets(parent);
for (int i = 0; i < kids.count(); ++i) {
if (QLabel *labelSibling = qobject_cast<QLabel*>(kids.at(i))) {
if (labelSibling->buddy() == widget()) {
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(labelSibling);
rels.append(qMakePair(iface, rel));
}
}
}
#endif
#ifndef QT_NO_GROUPBOX
QGroupBox *groupbox = qobject_cast<QGroupBox*>(parent);
if (groupbox && !groupbox->title().isEmpty()) {
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(groupbox);
rels.append(qMakePair(iface, rel));
}
#endif
}
}
if (match & QAccessible::Controlled) {
QObjectList allReceivers;
QACConnectionObject *connectionObject = (QACConnectionObject*)object();
for (int sig = 0; sig < d->primarySignals.count(); ++sig) {
const QObjectList receivers = connectionObject->receiverList(d->primarySignals.at(sig).toLatin1());
allReceivers += receivers;
}
allReceivers.removeAll(object()); //### The object might connect to itself internally
for (int i = 0; i < allReceivers.count(); ++i) {
const QAccessible::Relation rel = QAccessible::Controlled;
QAccessibleInterface *iface = QAccessible::queryAccessibleInterface(allReceivers.at(i));
if (iface)
rels.append(qMakePair(iface, rel));
}
}
return rels;
}
示例15: dropInPlace
void PopupMenuEditor::dropInPlace( QActionGroup * g, int y )
{
if (!g->children())
return;
QObjectList l = *g->children();
for ( int i = 0; i < (int)l.count(); ++i ) {
QAction *a = ::qt_cast<QAction*>(l.at(i));
QActionGroup *g = ::qt_cast<QActionGroup*>(l.at(i));
if ( g )
dropInPlace( g, y );
else if ( a )
dropInPlace( new PopupMenuEditorItem( a, this ), y );
}
}