我是靠谱客的博主 哭泣小馒头,最近开发中收集的这篇文章主要介绍Qt 之 QChildEvent::child方法QChildEventDemo1: childEvent一个纯净的网站,觉得挺不错的,现在分享给大家,希望可以做个参考。
概述
QChildEvent
Child events are sent immediately to objects when children are added or removed.
Demo1: childEvent
开发者ID:KDE,项目名称:tupi,代码行数:29,代码来源:tvhbox.cpp
void KoVBox::childEvent(QChildEvent *event)
{
switch (event->type()) {
case QEvent::ChildAdded: {
QChildEvent *childEvent = static_cast<QChildEvent *>(event);
if (childEvent->child()->isWidgetType()) {
QWidget *widget = static_cast<QWidget *>(childEvent->child());
static_cast<QBoxLayout *>(layout())->addWidget(widget);
}
break;
}
case QEvent::ChildRemoved: {
QChildEvent *childEvent = static_cast<QChildEvent *>(event);
if (childEvent->child()->isWidgetType()) {
QWidget *widget = static_cast<QWidget *>(childEvent->child());
static_cast<QBoxLayout *>(layout())->removeWidget(widget);
}
break;
}
default:
break;
}
QFrame::childEvent(event);
}
Demo2:event
开发者ID:BackupTheBerlios,项目名称:sim-im-svn,代码行数:29,代码来源:zodiak.cpp
bool TVHBox::event(QEvent* ev)
{
switch (ev->type()) {
case QEvent::ChildAdded:
{
QChildEvent* childEv = static_cast<QChildEvent *>(ev);
if (childEv->child()->isWidgetType()) {
QWidget* w = static_cast<QWidget *>(childEv->child());
static_cast<QBoxLayout *>(layout())->addWidget(w);
}
return QWidget::event(ev);
}
case QEvent::ChildRemoved:
{
QChildEvent* childEv = static_cast<QChildEvent *>(ev);
if (childEv->child()->isWidgetType()) {
QWidget* w = static_cast<QWidget *>(childEv->child());
static_cast<QBoxLayout *>(layout())->removeWidget(w);
}
return QWidget::event(ev);
}
default:
return QWidget::event(ev);
}
}
一个纯净的网站
https://vimsky.com/examples/
最后
以上就是哭泣小馒头为你收集整理的Qt 之 QChildEvent::child方法QChildEventDemo1: childEvent一个纯净的网站的全部内容,希望文章能够帮你解决Qt 之 QChildEvent::child方法QChildEventDemo1: childEvent一个纯净的网站所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复