Qt 窗体焦点问题

void setWidgetFocusPolicy(QWidget *widget, Qt::FocusPolicy policy)
{
    foreach(QObject *child, widget->children())
    {
        if(QWidget *childW = qobject_cast(child))
            setWidgetFocusPolicy(childW, policy);
    }

    widget->setFocusPolicy(policy);
}

 

void setWidgetFocusProxy(QWidget *widget, QWidget *proxy)
{
    foreach(QObject *child, widget->children())
    {
        if(QWidget *childW = qobject_cast(child))
            setWidgetFocusProxy(childW, proxy);
    }

    widget->setFocusProxy(proxy);
}

你可能感兴趣的:(笔记)