예제 #1
0
/*! \reimp */
QAccessible::Relation QAccessibleApplication::relationTo(int child, const
        QAccessibleInterface *other, int otherChild) const
{
    QObject *o = other ? other->object() : 0;
    if (!o)
        return Unrelated;

    if(o == object()) {
        if (child && !otherChild)
            return Child;
        if (!child && otherChild)
            return Ancestor;
        if (!child && !otherChild)
            return Self;
    }

    QWidgetList tlw(topLevelWidgets());
    if (tlw.contains(qobject_cast<QWidget*>(o)))
        return Ancestor;

    for (int i = 0; i < tlw.count(); ++i) {
        QWidget *w = tlw.at(i);
        QObjectList cl = w->findChildren<QObject *>(QString());
        if (cl.contains(o))
            return Ancestor;
    }

    return Unrelated;
}
예제 #2
0
/**
 * this is only for pre 4.2 code !
 * http://ariya.ofilabs.com/2007/04/custom-toggle-action-for-qdockwidget.html
 */
bool MainWindow::eventFilter(QObject *obj, QEvent *e)
{

    
    QObjectList windowChildren = children();
    QDockWidget *w;
    
    if (e->type() == QEvent::Close && windowChildren.contains(obj)) {
        if ((w = dynamic_cast<QDockWidget *>(obj)) != NULL) {
            
            QList<QAction*> actions = findChildren<QAction *>();
            for (int i = 0; i < actions.size(); i++) {
                if (actions.at(i)->text() == w->objectName()) {
                    actions.at(i)->setChecked(false);
                    return true;
                }
            }
            
        }
    }

    return QObject::eventFilter(object, event);
    //return false;
}