Ported QWidget inject code.
Reviewed by Lauro Moura <lauro.neto@openbossa.org>
This commit is contained in:
parent
3b41e70376
commit
ecf529ce6a
2 changed files with 45 additions and 2 deletions
39
PySide/QtGui/glue/qwidget_glue.h
Normal file
39
PySide/QtGui/glue/qwidget_glue.h
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
/**
|
||||||
|
* Tranfer objects ownership from layout to widget
|
||||||
|
**/
|
||||||
|
static inline void
|
||||||
|
qwidgetReparentLayout(QWidget *parent, QLayout *layout)
|
||||||
|
{
|
||||||
|
Shiboken::AutoDecRef pyParent(Shiboken::Converter<QWidget*>::toPython(parent));
|
||||||
|
|
||||||
|
for (int i=0; i < layout->count(); i++)
|
||||||
|
{
|
||||||
|
QLayoutItem *item = layout->itemAt(i);
|
||||||
|
QWidget *w = item->widget();
|
||||||
|
|
||||||
|
if (w)
|
||||||
|
{
|
||||||
|
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QWidget*>::toPython(w));
|
||||||
|
Shiboken::setParent(pyParent, pyChild);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
QLayout *l = item->layout();
|
||||||
|
if (l)
|
||||||
|
qwidgetReparentLayout(parent, l);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Shiboken::AutoDecRef pyChild(Shiboken::Converter<QLayout*>::toPython(layout));
|
||||||
|
Shiboken::setParent(pyParent, pyChild);
|
||||||
|
}
|
||||||
|
|
||||||
|
static inline void
|
||||||
|
qwidgetSetLayout(QWidget *self, QLayout *layout)
|
||||||
|
{
|
||||||
|
if (self->layout())
|
||||||
|
return;
|
||||||
|
|
||||||
|
qwidgetReparentLayout(self, layout);
|
||||||
|
self->setLayout(layout);
|
||||||
|
}
|
||||||
|
|
@ -2568,6 +2568,7 @@
|
||||||
<extra-includes>
|
<extra-includes>
|
||||||
<include file-name="QIcon" location="global"/>
|
<include file-name="QIcon" location="global"/>
|
||||||
<include file-name="QMessageBox" location="global"/>
|
<include file-name="QMessageBox" location="global"/>
|
||||||
|
<include file-name="glue/qwidget_glue.h" location="local"/>
|
||||||
</extra-includes>
|
</extra-includes>
|
||||||
|
|
||||||
<modify-function signature="actionEvent(QActionEvent*)">
|
<modify-function signature="actionEvent(QActionEvent*)">
|
||||||
|
|
@ -2682,8 +2683,11 @@
|
||||||
</modify-argument>
|
</modify-argument>
|
||||||
</modify-function>
|
</modify-function>
|
||||||
|
|
||||||
<!-- Will use glue code -->
|
<modify-function signature="setLayout(QLayout *)">
|
||||||
<modify-function signature="setLayout(QLayout *)" remove="all"/>
|
<inject-code class="target" position="beginning">
|
||||||
|
qwidgetSetLayout(%CPPSELF, %1);
|
||||||
|
</inject-code>
|
||||||
|
</modify-function>
|
||||||
<modify-function signature="enabledChange(bool)" remove="all"/>
|
<modify-function signature="enabledChange(bool)" remove="all"/>
|
||||||
<!--### Obsolete in 4.3-->
|
<!--### Obsolete in 4.3-->
|
||||||
<modify-function signature="fontChange(QFont)" remove="all"/>
|
<modify-function signature="fontChange(QFont)" remove="all"/>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue