[Qt-interest] pos() bug

Alex Custov alex.custov at gmail.com
Fri Feb 20 15:33:40 CET 2009


Hi.

I'm using Debian Lenny and Qt 4.4.3, KDE 3.5.10.

I tried to run a "shapedclock" example from Qt package. Qt seems to
have one very important bug: it doesn't update window position at
first run. Similar bug:
https://bugzilla.redhat.com/show_bug.cgi?id=426354. I added some debug
mesages into the source code as follows:

void ShapedClock::mousePressEvent(QMouseEvent *event)
{
    if (event->button() == Qt::LeftButton) {
        dragPosition = event->globalPos() - frameGeometry().topLeft();
        qDebug() << "klik" << dragPosition;
        event->accept();
    }
}

void ShapedClock::mouseMoveEvent(QMouseEvent *event)
{
    if (event->buttons() & Qt::LeftButton) {
        qDebug() << "move" << pos() << event->globalPos() <<
dragPosition << (event->globalPos() - dragPosition);
        move(event->globalPos() - dragPosition);
        event->accept();
    }
}

What I got:
klik QPoint(639,525)
move QPoint(0,0) QPoint(640,525) QPoint(639,525) QPoint(1,0)

Initially this window with clock inside is positioned by window
manager at the center of the screen, but pos() returns QPoint(0, 0) !
That's why in the next moment this window jumps to the left top corner
of the screen.

Any ideas how to fix it? Thanks.

P.S.The bug is not present in Qt 3.3.8.

--



More information about the Qt-interest-old mailing list