コード例 #1
0
/*override*/ bool FileRenamerDlgImpl::eventFilter(QObject* pObj, QEvent* pEvent)
{
//qDebug("ev %d", int(pEvent->type()));
    if (QEvent::ChildAdded == pEvent->type())
    {
        //qDebug("add");
        QObject* pChild (((QChildEvent*)pEvent)->child());
        if (pChild->isWidgetType())
        {
            CB_ASSERT (0 == m_pEditor);
            m_pEditor = pChild;
        }
    }
    else if (QEvent::ChildRemoved == pEvent->type())
    {
        //qDebug("rm");
        QObject* pChild (((QChildEvent*)pEvent)->child());
        if (pChild->isWidgetType())
        {
            CB_ASSERT (pChild == m_pEditor);
            m_pEditor = 0;
        }
    }
    return QDialog::eventFilter(pObj, pEvent);
}
コード例 #2
0
ファイル: qwidget_qws.cpp プロジェクト: Miguel-J/eneboo-core
QRegion QWidget::allocatedRegion() const
{
    if (isVisible()) {
	if ( isTopLevel() ) {
	    return alloc_region;
	} else {
	    if ( isAllocatedRegionDirty() ) {
		const QObjectList *c;
		QRegion r( req_region );
		r &= parentWidget()->allocatedRegion();
		parentWidget()->updateOverlappingChildren();
		if ( parentWidget()->overlapping_children ) {
		    c = parentWidget()->children();
		    if ( c ) {
			QObjectListIt it(*c);
			QObject* ch;
			bool clip=FALSE;
			while ((ch=it.current())) {
			    ++it;
			    if ( ch->isWidgetType() ) {
				QWidget *w = (QWidget*)ch;
				if ( w == this )
				    clip=TRUE;
				else if ( clip && !w->isTopLevel() && w->isVisible() ) {
				    if ( w->geometry().intersects( geometry() ) )
					r -= w->req_region;
				}
			    }
			}
		    }
		}

		// if I'm dirty, so are my chlidren.
		c = children();
		if ( c ) {
		    QObjectListIt it(*c);
		    QObject* ch;
		    while ((ch=it.current())) {
			++it;
			if ( ch->isWidgetType() && !((QWidget*)ch)->isTopLevel() ) {
			    ((QWidget *)ch)->alloc_region_dirty = TRUE;
			}
		    }
		}

		alloc_region = r;
		alloc_region_dirty = FALSE;
		paintable_region_dirty = TRUE;
	    }
	    return alloc_region;
	}
    } else {
	return QRegion();
    }
}
コード例 #3
0
ファイル: objectinspector.cpp プロジェクト: Fale/qtmoko
void ObjectInspector::ObjectInspectorPrivate::synchronizeSelection(const QItemSelection & selectedSelection, const QItemSelection &deselectedSelection)
{
    // Synchronize form window cursor.
    const QObjectVector deselected = indexesToObjects(m_model, deselectedSelection.indexes());
    const QObjectVector newlySelected = indexesToObjects(m_model, selectedSelection.indexes());

    const QModelIndexList currentSelectedIndexes = m_treeView->selectionModel()->selectedRows(0);

    int deselectedManagedWidgetCount = 0;
    if (!deselected.empty())
        deselectedManagedWidgetCount = selectInCursor(m_formWindow, deselected, false);

    if (newlySelected.empty()) { // Nothing selected
        if (currentSelectedIndexes.empty()) // Do not allow a null-selection, reset to main container
            m_formWindow->clearSelection(!m_withinClearSelection);
        return;
    }

    const int selectManagedWidgetCount = selectInCursor(m_formWindow, newlySelected, true);
    // Check consistency: Make sure either  managed widgets or  unmanaged objects are selected.
    // No newly-selected managed widgets: Unless there are ones in the (old) current selection,
    // select the unmanaged object
    if (selectManagedWidgetCount == 0) {
        if (checkManagedWidgetSelection(currentSelectedIndexes)) {
            // Managed selection exists, refuse and update if necessary
            if (deselectedManagedWidgetCount != 0 || selectManagedWidgetCount != 0)
                m_formWindow->emitSelectionChanged();
            return;
        }
        // And now for the unmanaged selection
        m_formWindow->clearSelection(false);
        QObject *unmanagedObject = newlySelected.front();
        m_core->propertyEditor()->setObject(unmanagedObject);
        m_core->propertyEditor()->setEnabled(true);
        // open container page if it is a single widget
        if (newlySelected.size() == 1 && unmanagedObject->isWidgetType())
            showContainersCurrentPage(static_cast<QWidget*>(unmanagedObject));
        return;
    }
    // Open container page if it is a single widget
    if (newlySelected.size() == 1) {
        QObject *object = newlySelected.back();
        if (object->isWidgetType())
            showContainersCurrentPage(static_cast<QWidget*>(object));
    }

    // A managed widget was newly selected. Make sure  there are no unmanaged objects
    // in the whole unless just single selection
    if (currentSelectedIndexes.size() > selectManagedWidgetCount)
        checkManagedWidgetSelection(currentSelectedIndexes);
    // Update form
    if (deselectedManagedWidgetCount != 0 || selectManagedWidgetCount != 0)
        m_formWindow->emitSelectionChanged();
}
コード例 #4
0
ファイル: actiondnd.cpp プロジェクト: app/ananas-labs
QPoint QDesignerToolBar::calcIndicatorPos( const QPoint &pos )
{
    if ( orientation() == Horizontal ) {
	QPoint pnt( width() - 2, 0 );
	insertAnchor = 0;
	afterAnchor = TRUE;
	if ( !children() )
	    return pnt;
	pnt = QPoint( 13, 0 );
	QObjectListIt it( *children() );
	QObject * obj;
	while( (obj=it.current()) != 0 ) {
	    ++it;
	    if ( obj->isWidgetType() &&
		 qstrcmp( "qt_dockwidget_internal", obj->name() ) != 0 ) {
		QWidget *w = (QWidget*)obj;
		if ( w->x() < pos.x() ) {
		    pnt.setX( w->x() + w->width() + 1 );
		    insertAnchor = w;
		    afterAnchor = TRUE;
		}
	    }
	}
	return pnt;
    } else {
	QPoint pnt( 0, height() - 2 );
	insertAnchor = 0;
	afterAnchor = TRUE;
	if ( !children() )
	    return pnt;
	pnt = QPoint( 0, 13 );
	QObjectListIt it( *children() );
	QObject * obj;
	while( (obj=it.current()) != 0 ) {
	    ++it;
	    if ( obj->isWidgetType() &&
		 qstrcmp( "qt_dockwidget_internal", obj->name() ) != 0 ) {
		QWidget *w = (QWidget*)obj;
		if ( w->y() < pos.y() ) {
		    pnt.setY( w->y() + w->height() + 1 );
		    insertAnchor = w;
		    afterAnchor = TRUE;
		}
	    }
	}
	return pnt;
    }
}
コード例 #5
0
ファイル: qwidgetstack.cpp プロジェクト: aroraujjwal/qt3
/*!
    \reimp
*/
void QWidgetStack::show()
{
    //  Reimplemented in order to set the children's geometries
    //  appropriately and to pick the first widget as topWidget if no
    //  topwidget was defined
    if ( !isVisible() && children() ) {
	const QObjectList * c = children();
	QObjectListIt it( *c );
	QObject * o;

	while( (o=it.current()) != 0 ) {
	    ++it;
	    if ( o->isWidgetType() ) {
		if ( !topWidget && o != invisible )
		    topWidget = (QWidget*)o;
		if ( o == topWidget )
		    ((QWidget *)o)->show();
		else
		    ((QWidget *)o)->hide();
	    }
	}
	setChildGeometries();
    }
    QFrame::show();
}
コード例 #6
0
ファイル: flowlayout.cpp プロジェクト: NotLemon/Shinjiru
int FlowLayout::smartSpacing(QStyle::PixelMetric t_pm) const {
    if ((t_pm == QStyle::PM_LayoutHorizontalSpacing) &&
            (m_item_list.count() > 0) && (this->geometry().width() > 0)) {
        qreal refWidth = 40. / 2736.;
        QRect rect = qApp->primaryScreen()->geometry();
        int newWidth = static_cast<int>(rect.width() * refWidth + 1);

        auto width = this->geometry().width() - newWidth;
        auto single_width = m_item_list.first()->widget()->width();
        if (single_width == 0) return 0;
        int items_per_row = width / single_width;
        if (items_per_row == 0) items_per_row = 1;

        auto extra_space = width - single_width * items_per_row;

        if (items_per_row == 1) return extra_space;

        return extra_space / (items_per_row - 1) - 1;
    }

    QObject *parent = this->parent();

    if (!parent) {
        return -1;
    } else if (parent->isWidgetType()) {
        QWidget *pw = static_cast<QWidget *>(parent);
        return pw->style()->pixelMetric(t_pm, 0, pw);
    } else {
        return static_cast<QLayout *>(parent)->spacing();
    }
}
コード例 #7
0
void QDesignerIntegrationPrivate::getSelection(Selection &s)
{
    QDesignerFormEditorInterface *core = q->core();
    // Get multiselection from object inspector
    if (QDesignerObjectInspector *designerObjectInspector = qobject_cast<QDesignerObjectInspector *>(core->objectInspector())) {
        designerObjectInspector->getSelection(s);
        // Action editor puts actions that are not on the form yet
        // into the property editor only.
        if (s.empty())
            if (QObject *object = core->propertyEditor()->object())
                s.objects.push_back(object);

    } else {
        // Just in case someone plugs in an old-style object inspector: Emulate selection
        s.clear();
        QDesignerFormWindowInterface *formWindow = core->formWindowManager()->activeFormWindow();
        if (!formWindow)
            return;

        QObject *object = core->propertyEditor()->object();
        if (object->isWidgetType()) {
            QWidget *widget = static_cast<QWidget*>(object);
            QDesignerFormWindowCursorInterface *cursor = formWindow->cursor();
            if (cursor->isWidgetSelected(widget)) {
                s.managed.push_back(widget);
            } else {
                s.unmanaged.push_back(widget);
            }
        } else {
            s.objects.push_back(object);
        }
    }
}
コード例 #8
0
ファイル: CQGroupBox.cpp プロジェクト: colinw7/CQGroupBox
void
CQGroupBox::
updateEnabled()
{
  bool enabled = isEnabled();

  QObjectList childList = children();

  for (int i = 0; i < childList.size(); ++i) {
    QObject *o = childList.at(i);

    if (! o->isWidgetType()) continue;

    QWidget *w = static_cast<QWidget *>(o);

    if (isCheckable()) {
      if (isChecked()) {
//      if (! w->isEnabled()) {
//        if (! w->testAttribute(Qt::WA_ForceDisabled))
            w->setEnabled(true);
//      }
      }
      else {
//      if (w->isEnabled())
          w->setEnabled(false);
      }
    }
    else {
      w->setEnabled(enabled);
    }
  }
}
コード例 #9
0
ファイル: qwidget_qws.cpp プロジェクト: Miguel-J/eneboo-core
static void paint_children(QWidget * p,const QRegion& r, bool post)
{
    if(!p)
	return;
    QObjectList * childObjects=(QObjectList*)p->children();
    if(childObjects) {
	QObject * o;
	for(o=childObjects->first();o!=0;o=childObjects->next()) {
	    if( o->isWidgetType() ) {
		QWidget *w = (QWidget *)o;
		if ( w->testWState(Qt::WState_Visible) ) {
		    QRegion wr( QRegion(w->geometry()) & r );
		    if ( !wr.isEmpty() ) {
			wr.translate(-w->x(),-w->y());
			if ( post )
			    QApplication::postEvent(w,new QPaintEvent(wr,
				   !w->testWFlags(QWidget::WRepaintNoErase) ) );
			else
			    w->repaint(wr, !w->testWFlags(QWidget::WRepaintNoErase));
			paint_children(w,wr,post);
		    }
		}
	    }
	}
    }
}
コード例 #10
0
ファイル: qwidget_qws.cpp プロジェクト: Miguel-J/eneboo-core
void QWidget::updateRequestedRegion( const QPoint &gpos )
{
    if ( !isTopLevel() ) {
	if ( !testWState( WState_Visible ) || testWState(WState_ForceHide) ) {
	    req_region = QRegion();
	} else {
	    req_region = QRect(gpos,crect.size());
	    if ( extra && !extra->mask.isNull() ) {
		QRegion maskr = extra->mask;
		maskr.translate( gpos.x(), gpos.y() );
		req_region &= maskr;
	    }
	    req_region = qt_screen->mapToDevice( req_region, QSize(qt_screen->width(), qt_screen->height()) );
	}
    }
    const QObjectList *c = children();
    if ( c ) {
	QObjectListIt it(*c);
	QObject* ch;
	while ((ch=it.current())) {
	    ++it;
	    if ( ch->isWidgetType() && !((QWidget*)ch)->isTopLevel() ) {
		QWidget *w = (QWidget *)ch;
		w->updateRequestedRegion( gpos + w->pos() );
	    }
	}
    }
}
コード例 #11
0
ファイル: qwidget_qws.cpp プロジェクト: Miguel-J/eneboo-core
void QWidget::updateOverlappingChildren() const
{
    if ( overlapping_children != -1 || isSettingGeometry )
	return;

    QRegion r;
    const QObjectList *c = children();
    if ( c ) {
	QObjectListIt it(*c);
	QObject* ch;
	while ((ch=it.current())) {
	    ++it;
	    if ( ch->isWidgetType() && !((QWidget*)ch)->isTopLevel() ) {
		QWidget *w = (QWidget *)ch;
		if ( w->isVisible() ) {
		    QRegion rr( w->req_region );
		    QRegion ir = r & rr;
		    if ( !ir.isEmpty() ) {
			overlapping_children = 1;
			return;
		    }
		    r |= rr;
		}
	    }
	}
    }
    overlapping_children = 0;
}
コード例 #12
0
ファイル: qdnd_x11.cpp プロジェクト: kthxbyte/Qt1.45-Linaro
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;
}
コード例 #13
0
void SkinStyle::createWidgetsContainer(QWidget * widget, const QString & objectName) {
    QWidget * container = new QWidget(widget->parentWidget());
    container->setObjectName(objectName);

    QHBoxLayout * layout = new QHBoxLayout();
    container->setLayout(layout);

    QObjectList objects = widget->children();
    for (int i = 0; i < objects.size(); i++) {
        QObject * object = objects.at(i);

        if (object->isWidgetType()) {
            if (!object->inherits("QToolBarHandle") && !object->inherits("QToolBarExtension")) {
                QWidget * w = qobject_cast < QWidget * > (object);
                addWidgetToLayout(w, layout);
                w->show();
            }
        }

        else if (object->inherits("QAction")) {
            QAction * a = qobject_cast < QAction * > (object);
            QWidget * w = new QWidget(container);
            w->addAction(a);
            addWidgetToLayout(w, layout);
        }

        else if (object->inherits("QLayout")) {
            QLayout * l = qobject_cast < QLayout * > (object);
            layout->addLayout(l);
        }
    }

    container->show();
}
コード例 #14
0
ファイル: qdnd_x11.cpp プロジェクト: AliYousuf/abanq-port
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;
}
コード例 #15
0
//-----------------------------------------------------------------------------
void ctkCollapsibleGroupBox::expand(bool _expand)
{
  if (!_expand)
    {
    this->OldSize = this->size();
    }

  QObjectList childList = this->children();
  for (int i = 0; i < childList.size(); ++i) 
    {
    QObject *o = childList.at(i);
    if (o && o->isWidgetType()) 
      {
      QWidget *w = static_cast<QWidget *>(o);
      if ( w )
        {
        w->setVisible(_expand);
        }
      }
    }
  
  if (_expand)
    {
    this->setMaximumHeight(this->MaxHeight);
    this->resize(this->OldSize);
    }
  else
    {
    this->MaxHeight = this->maximumHeight();
    this->setMaximumHeight(22);
    }
}
コード例 #16
0
ファイル: KviWindow.cpp プロジェクト: Cizzle/KVIrc
void KviWindow::focusInEvent(QFocusEvent *)
{
	if(m_pLastFocusedChild)
	{
		if(m_pLastFocusedChild->hasFocus() && m_pLastFocusedChild->isVisible())
		{
			// focus is still in this window.
			// just make sure that we're the active one.
			if(g_pActiveWindow != this)
				g_pMainWindow->windowActivated(this);
			return;
		}
	}

	// focus doesn't seem to be in this window
	if(!m_pFocusHandler)
	{
		// figure out a child to give focus to.
		// we probably have no KviInput since it would have been grabbed anyway

		if(m_pIrcView)
			m_pFocusHandler = m_pIrcView;
		else
		{
			for(auto & it : children())
			{
				QObject * pObj = it;
				if(pObj->isWidgetType())
				{
					m_pFocusHandler = (QWidget *)pObj;
					break;
				}
			}
		}

		if(m_pFocusHandler)
			m_pFocusHandler->setFocus();
		else
		{
			// else too bad :/
			qDebug("No widget able to handle focus for window %s", objectName().toUtf8().data());
			updateCaption(); // do it anyway
			return;
		}
	}
	else
	{
		m_pFocusHandler->setFocus();
	}

	// Setting the focus to the focus handler usually
	// triggers our filter for the children's focusInEvent
	// which in turn should invoke our filter and make this window the active one.
	// So we should be already the active window at this point.
	// If we're not, then fix this.
	if(g_pActiveWindow != this)
		g_pMainWindow->windowActivated(this);

	updateCaption();
}
コード例 #17
0
void KCMStyle::setStyleRecursive(QWidget* w, QStyle* s)
{
	// Don't let broken styles kill the palette
	// for other styles being previewed. (e.g SGI style)
	w->unsetPalette();

	QPalette newPalette(KApplication::createApplicationPalette());
	s->polish( newPalette );
	w->setPalette(newPalette);

	// Apply the new style.
	w->setStyle(s);

	// Recursively update all children.
	const QObjectList *children = w->children();
	if (!children)
		return;

	// Apply the style to each child widget.
	QPtrListIterator<QObject> childit(*children);
	QObject *child;
	while ((child = childit.current()) != 0)
	{
		++childit;
		if (child->isWidgetType())
			setStyleRecursive((QWidget *) child, s);
	}
}
コード例 #18
0
ファイル: qaction.cpp プロジェクト: 3163504123/phantomjs
/*!
    Returns the parent widget.
*/
QWidget *QAction::parentWidget() const
{
    QObject *ret = parent();
    while (ret && !ret->isWidgetType())
        ret = ret->parent();
    return (QWidget*)ret;
}
コード例 #19
0
ファイル: KviWindow.cpp プロジェクト: Cizzle/KVIrc
void KviWindow::childInserted(QWidget * pObject)
{
	pObject->removeEventFilter(this);  // ensure that we don't filter twice
	pObject->installEventFilter(this); // we filter its events

	connect(pObject, SIGNAL(destroyed()), this, SLOT(childDestroyed()));

	// attempt to grab a decent focus handler

	if(pObject->inherits("KviInput"))
	{
		// KviInput is our preferential focus handler
		m_pFocusHandler = pObject;
	}
	else
	{
		// not a KviInput
		if(!m_pFocusHandler && (pObject->focusPolicy() == Qt::StrongFocus))
		{
			// still without a focus handler: take this widget (possibly only temporarily)
			m_pFocusHandler = pObject;
		}
	}

	for(auto & it : pObject->children())
	{
		QObject * pObj = it;
		if(pObj->isWidgetType())
			childInserted((QWidget *)pObj);
	}
}
コード例 #20
0
ファイル: qwidget_qws.cpp プロジェクト: Afreeca/qt
void QWidgetPrivate::raise_sys()
{
    Q_Q(QWidget);
    //@@@ transaction
    if (q->isWindow()) {
        Q_ASSERT(q->testAttribute(Qt::WA_WState_Created));
        QWidget::qwsDisplay()->setAltitude(q->internalWinId(),
                                           QWSChangeAltitudeCommand::Raise);
        // XXX: subsurfaces?
#ifdef QT_NO_WINDOWGROUPHINT
#else
        QObjectList childObjects =  q->children();
        if (!childObjects.isEmpty()) {
            QWidgetList toraise;
            for (int i = 0; i < childObjects.size(); ++i) {
                QObject *obj = childObjects.at(i);
                if (obj->isWidgetType()) {
                    QWidget* w = static_cast<QWidget*>(obj);
                    if (w->isWindow())
                        toraise.append(w);
                }
            }

            for (int i = 0; i < toraise.size(); ++i) {
                QWidget *w = toraise.at(i);
                if (w->isVisible())
                    w->raise();
            }
        }
#endif // QT_NO_WINDOWGROUPHINT
    }
}
コード例 #21
0
ファイル: mythuitype.cpp プロジェクト: masjerang/mythtv
static QObject *qChildHelper(const char *objName, const char *inheritsClass,
                             bool recursiveSearch, const QObjectList &children)
{
    if (children.isEmpty())
        return 0;

    bool onlyWidgets = (inheritsClass
                        && qstrcmp(inheritsClass, "QWidget") == 0);
    const QLatin1String oName(objName);

    for (int i = 0; i < children.size(); ++i)
    {
        QObject *obj = children.at(i);

        if (onlyWidgets)
        {
            if (obj->isWidgetType() && (!objName || obj->objectName() == oName))
                return obj;
        }
        else if ((!inheritsClass || obj->inherits(inheritsClass))
                 && (!objName || obj->objectName() == oName))
            return obj;

        if (recursiveSearch && (dynamic_cast<MythUIGroup *>(obj) != NULL)
            && (obj = qChildHelper(objName, inheritsClass,
                                   recursiveSearch,
                                   obj->children())))
            return obj;
    }

    return 0;
}
コード例 #22
0
ファイル: qwt_picker.cpp プロジェクト: NREL/OpenStudio
//! Return the parent widget, where the selection happens
const QWidget *QwtPicker::parentWidget() const
{
    QObject *obj = parent();
    if ( obj && obj->isWidgetType() )
        return static_cast< const QWidget *>( obj );

    return NULL;
}
コード例 #23
0
ファイル: qwt_picker.cpp プロジェクト: chongle/prorata
//! Return the parent widget, where the selection happens
const QWidget *QwtPicker::parentWidget() const
{
    QObject *obj = parent();
    if ( obj && obj->isWidgetType() )
        return (QWidget *)obj;

    return NULL;
}
コード例 #24
0
ファイル: qwidget_qws.cpp プロジェクト: Afreeca/qt
void QWidget::destroy(bool destroyWindow, bool destroySubWindows)
{
    Q_D(QWidget);
    d->aboutToDestroy();
    if (!isWindow() && parentWidget())
        parentWidget()->d_func()->invalidateBuffer(d->effectiveRectFor(geometry()));

    d->deactivateWidgetCleanup();
    if (testAttribute(Qt::WA_WState_Created)) {
        setAttribute(Qt::WA_WState_Created, false);
        QObjectList childObjects =  children();
        for (int i = 0; i < childObjects.size(); ++i) {
            QObject *obj = childObjects.at(i);
            if (obj->isWidgetType())
                static_cast<QWidget*>(obj)->destroy(destroySubWindows,
                                                     destroySubWindows);
        }
        releaseMouse();
        if (qt_pressGrab == this)
          qt_pressGrab = 0;

        if (keyboardGrb == this)
            releaseKeyboard();
        if (testAttribute(Qt::WA_ShowModal))                // just be sure we leave modal
            QApplicationPrivate::leaveModal(this);
        else if ((windowType() == Qt::Popup))
            qApp->d_func()->closePopup(this);
#ifndef QT_NO_IM
        if (d->ic) {
            delete d->ic;
            d->ic =0;
        } else {
            // release previous focus information participating with
            // preedit preservation of qic -- while we still have a winId
            QInputContext *qic = QApplicationPrivate::inputContext;
            if (qic)
                qic->widgetDestroyed(this);
        }
#endif //QT_NO_IM

        if ((windowType() == Qt::Desktop)) {
        } else {
            if (parentWidget() && parentWidget()->testAttribute(Qt::WA_WState_Created)) {
                d->hide_sys();
            }
            if (destroyWindow && isWindow()) {
                if (d->extra && d->extra->topextra && d->extra->topextra->backingStore)
                    d->extra->topextra->backingStore->windowSurface->setGeometry(QRect());
                qwsDisplay()->destroyRegion(internalWinId());
            }
        }
        QT_TRY {
            d->setWinId(0);
        } QT_CATCH (const std::bad_alloc &) {
            // swallow - destructors must not throw
        }
    }
}
コード例 #25
0
/*!    
    Takes a screen shot of \link target\endlink, and returns true if the screen shot is successfully saved 
    to \link fileName\endlink.
*/
bool QchScreenShot::grab() {
    Q_D(QchScreenShot);
    d->pixmap = QPixmap();
    
    QObject *obj = target();
    
    if (obj) {
        if (obj->isWidgetType()) {
            QWidget *widget = qobject_cast<QWidget*>(obj);
            
            if (widget) {
                d->pixmap = QPixmap::grabWidget(widget, targetX(), targetY(), targetWidth(), targetHeight());
            }
        }
        else if (QGraphicsObject *go = qobject_cast<QGraphicsObject*>(obj)) {
            QRect rect = go->boundingRect().toRect();
            rect.moveLeft(qMax(0, targetX()));
            rect.moveTop(qMax(0, targetY()));
            rect.setWidth(qBound(1, targetWidth(), rect.width()));
            rect.setHeight(qBound(1, targetHeight(), rect.height()));
            
            QStyleOptionGraphicsItem styleOption;
            styleOption.rect = rect;
            
            d->pixmap = QPixmap(rect.size());
            d->pixmap.fill(Qt::transparent);
            
            QPainter painter(&d->pixmap);
            go->paint(&painter, &styleOption);
        }
        else {
            qmlInfo(this) << tr("Target must be a visual item.");
            return false;
        }
    }
    else {
        d->pixmap = QPixmap::grabWindow(QApplication::desktop()->winId(), targetX(), targetY(), targetWidth(),
                                        targetHeight());
    }

    if (!d->pixmap.isNull()) {
        QString name = d->getFileName();

        if (!name.isEmpty()) {
            setFileName(name);

            if ((width() > 0) && (height() > 0)) {
                d->pixmap = d->pixmap.scaled(width(), height(), Qt::IgnoreAspectRatio,
                                             smooth() ? Qt::SmoothTransformation : Qt::FastTransformation);
            }

            return d->pixmap.save(name);
        }
    }

    return false;
}
コード例 #26
0
ファイル: mainwindow.cpp プロジェクト: venkatarajasekhar/Qt
static void setStyleHelper(QWidget *w, QStyle *s)
{
    const QObjectList children = w->children();
    for (int i = 0; i < children.size(); ++i) {
        QObject *child = children.at(i);
        if (child->isWidgetType())
            setStyleHelper((QWidget *) child, s);
    }
    w->setStyle(s);
}
コード例 #27
0
bool QWidgetProxy::setParent( QObjectProxy *parentProxy )
{
  QObject *parent = parentProxy->object();
  if( !parent || !widget() ) return true;

  if( parent->isWidgetType() ) {
    QWidget *pw = qobject_cast<QWidget*>(parent);
    bool ok = pw->metaObject()->invokeMethod( pw, "addChild", Q_ARG( QWidget*, widget() ) );
    if( !ok ) widget()->setParent( pw );
    return true;
  }
コード例 #28
0
ファイル: FlowLayout.cpp プロジェクト: Visse/StreamingPlayer
int FlowLayout::smartSpacing(QStyle::PixelMetric pm) const
{
    QObject *parent = this->parent();
    if (!parent) {
        return -1;
    } else if (parent->isWidgetType()) {
        QWidget *pw = static_cast<QWidget *>(parent);
        return pw->style()->pixelMetric(pm, 0, pw);
    } else {
        return static_cast<QLayout *>(parent)->spacing();
    }
}
コード例 #29
0
Q_GUI_EXPORT int qSmartSpacing(const QLayout *layout, QStyle::PixelMetric pm)
{
    QObject *parent = layout->parent();
    if (!parent) {
        return -1;
    } else if (parent->isWidgetType()) {
        QWidget *pw = static_cast<QWidget *>(parent);
        return pw->style()->pixelMetric(pm, 0, pw);
    } else {
        return static_cast<QLayout *>(parent)->spacing();
    }
}
コード例 #30
0
QStackedWidgetEventFilter *QStackedWidgetEventFilter::eventFilterOf(const QStackedWidget *stackedWidget)
{
    // Look for 1st order children only..otherwise, we might get filters of nested widgets
    const QObjectList children = stackedWidget->children();
    const QObjectList::const_iterator cend = children.constEnd();
    for (QObjectList::const_iterator it = children.constBegin(); it != cend; ++it) {
        QObject *o = *it;
        if (!o->isWidgetType())
            if (QStackedWidgetEventFilter *ef = qobject_cast<QStackedWidgetEventFilter *>(o))
                return ef;
    }
    return 0;
}