t-artistik / qtscriptgenerator

Automatically exported from code.google.com/p/qtscriptgenerator
0 stars 0 forks source link

All properties of object are not accessible from a base class reference variable #34

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
I noticed this issue when trying to implement an event filter. 

What steps will reproduce the problem?

Run the following code with qs_eval:

function ChildWidget(parent)
{
    QPushButton.call(this, "Press here", parent);
}

ChildWidget.prototype = new QPushButton();

function ParentWidget()
{
    QWidget.call(this);

    var child = new ChildWidget(this);

    child.installEventFilter(this);
}

ParentWidget.prototype = new QWidget();

ParentWidget.prototype.eventFilter = function(obj, event)
{
    if (event.type() == QEvent.MouseButtonPress)
    {
        // this causes an exception because QMouseEvent's pos function
        // cannot be found 
        var pos = event.pos();
        print(pos);
    }
}

var widget = new ParentWidget();
widget.show();

QCoreApplication.exec();

What is the expected output? What do you see instead?
In the event filter, we have only access to QObject interface of obj and
QEvent interface of event. For example, there's no way to call the pos
function of event, even if we know that the event is of type MouseButtonPress. 

What version of the product are you using? On what operating system?
Qt 4.5.0-snapshot-20090127, Qt script generator commit
940bf9c93ef10aa3303245474f1698ce0cade941, Ubuntu Linux. 

Original issue reported on code.google.com by timo.pit...@sesca.com on 9 Feb 2009 at 12:24

GoogleCodeExporter commented 8 years ago
One interesting thing is that if you print 'event' in the above example, it 
prints
out a memory location instead of 'QEvent' like I've found it normally does.

Original comment by ian.mon...@gmail.com on 13 Feb 2009 at 6:49