aboutsummaryrefslogtreecommitdiffstats
path: root/tests/QtGui/parent_method_test.py
blob: 8d0ba960129b3a05f298843c086601db19688739 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25

import unittest

from PySide.QtCore import QObject, QTimer, QThread
from PySide.QtGui import *

class Foo(QTableView):
    def __init__(self, parent=None):
        QTableView.__init__(self, parent)

from helper import UsesQApplication

class TestParentType(UsesQApplication):

    def testParentType(self):
        # Test the problem with calling QObject.parent from a QWidget
        # when the parent is a python class derived from a QWidget-derived
        # class. The method was returning the last C++ class in the hierarchy
        parent = Foo()
        w2 = QWidget(parent)
        self.assert_(isinstance(w2.parentWidget(), Foo))
        self.assert_(isinstance(w2.parent(), Foo))

if __name__ == '__main__':
    unittest.main()