qboxlayout与qt布局(三)

     呃,,,记性总是不大好。每次找Qlayout的入口点时都要重新断点,真是的。好吧,把一些东西记一下下的。
QLayout是在哪里开始影响使用它的控件的呢?
    其实,是这样的,
    首先Qt的消息都是要经过 QApplication::notify()预先处理的,而对于 QApplication::notify()未处理的消息,就会通过调用QApplicationPrivate::notify_helper()来把消息发送到接收者那里去的。不过,在QApplicationPrivate::notify_helper()发消息到接收者那里去之前,它是会尝试调用一下下QLayout的widgetEvent()函数的,这样,就会跑到QLayout里面去,结果是QLayout把放在它里面的控件的size一一重新计算一遍的。代码如下:
bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e)
{
    // send to all application event filters
    if (sendThroughApplicationEventFilters(receiver, e))
        return true;


    if (receiver->isWidgetType()) {
        QWidget *widget = static_cast<QWidget *>(receiver);


#if !defined(Q_WS_WINCE) || (defined(GWES_ICONCURS) && !defined(QT_NO_CURSOR))
        // toggle HasMouse widget state on enter and leave
        if ((e->type() == QEvent::Enter || e->type() == QEvent::DragEnter) &&
            (!QApplication::activePopupWidget() || QApplication::activePopupWidget() == widget->window()))
            widget->setAttribute(Qt::WA_UnderMouse, true);
        else if (e->type() == QEvent::Leave || e->type() == QEvent::DragLeave)
            widget->setAttribute(Qt::WA_UnderMouse, false);
#endif

        // 嗯,就是这个入口啦~
        if (QLayout *layout=widget->d_func()->layout) {
            layout->widgetEvent(e);

        }
    }


    // send to all receiver event filters
    if (sendThroughObjectEventFilters(receiver, e))
        return true;


    // deliver the event
    bool consumed = receiver->event(e);
    e->spont = false;
    return consumed;
}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值