Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, August 2007
Qt 4.3 Perspective Transform bug ?


Message 1 in thread

Hi,

I seem to have run into an interesting feature/bug of QTransform for 
perspective transforms. If i have 2 widgets A & B, where A is the top level 
widget and B is its child, and i do a perspective transform inside the 
paintEvent for B, it only seems to work if B is positioned at 0,0. If B is 
moved with respect to its parent widget, the perspective transform doesnt 
work anymore, and it only does a translate/rotate/shear rather than a proper 
2D perspective transform.

Does anyone have any insight on why this is happening ?

thanks.
-gaurav


--
 [ signature omitted ] 

Message 2 in thread

Maybe you can show us a minimal, compilable example?

I suspect the bug is caused by mixing up relative/absolute coordinates
somewhere.

Cheers,
Peter

> -----Original Message-----
> From: Gaurav Bhatia [mailto:gnb@xxxxxxxxxxxxxx] 
> Sent: Monday, August 13, 2007 8:11 PM
> To: qt-interest@xxxxxxxxxxxxx
> Subject: Qt 4.3 Perspective Transform bug ?
> 
> 
> Hi,
> 
> I seem to have run into an interesting feature/bug of QTransform for 
> perspective transforms. If i have 2 widgets A & B, where A is 
> the top level 
> widget and B is its child, and i do a perspective transform 
> inside the 
> paintEvent for B, it only seems to work if B is positioned at 
> 0,0. If B is 
> moved with respect to its parent widget, the perspective 
> transform doesnt 
> work anymore, and it only does a translate/rotate/shear 
> rather than a proper 
> 2D perspective transform.
> 
> Does anyone have any insight on why this is happening ?
> 
> thanks.
> -gaurav
> 

--
 [ signature omitted ] 

Message 3 in thread

I have attached the code that i am using to test this. If you comment out 
the #define, you will see the expected output of the perspective transform.

/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CODE BEGIN
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
#include <QPaintEvent>
#include <QPainter>
#include <QWidget>
#include <QTransform>
#include <QApplication>

#define CHECK_BUG

class TransformExample : public QWidget {
public:
  TransformExample(QWidget *parent = 0);
protected:
  void paintEvent(QPaintEvent*);
};

TransformExample::TransformExample(QWidget *parent) : QWidget(parent) {
  setFixedSize(540,400);
#ifdef CHECK_BUG
  move(0,1);
#endif
}

void TransformExample::paintEvent(QPaintEvent* e) {
  QPainter dc(this);
  dc.setRenderHint(QPainter::Antialiasing);
  dc.setRenderHint(QPainter::SmoothPixmapTransform);
  dc.setTransform(QTransform(1,0,0,-0.54,0.2,-0.002,0,0,1));
  dc.setPen(QPen(Qt::gray,20));
  dc.drawLine(270,0,270,400);
}

int main(int argc, char* argv[]) {
  QApplication app(argc, argv);
#ifdef CHECK_BUG
  QWidget w;
  w.setFixedSize(640,480);
  TransformExample t(&w);
  w.show();
#else
  TransformExample t;
  t.show();
#endif
  return app.exec();
}
/////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CODE END
/////////////////////////////////////////////////////////////////////////////////////////////////////////////

-gaurav

> "Peter Prade" <prade@xxxxxxxxxxx> wrote in message 
> news:1C5B9B48EC79514FB4F4A7884ACFCB9F22457F@xxxxxxxxxxxxxxxxxxxxxxx
> Maybe you can show us a minimal, compilable example?
>
> I suspect the bug is caused by mixing up relative/absolute coordinates
> somewhere.
>
> Cheers,
> Peter
>
>> -----Original Message-----
>> From: Gaurav Bhatia [mailto:gnb@xxxxxxxxxxxxxx]
>> Sent: Monday, August 13, 2007 8:11 PM
>> To: qt-interest@xxxxxxxxxxxxx
>> Subject: Qt 4.3 Perspective Transform bug ?
>>
>>
>> Hi,
>>
>> I seem to have run into an interesting feature/bug of QTransform for
>> perspective transforms. If i have 2 widgets A & B, where A is
>> the top level
>> widget and B is its child, and i do a perspective transform
>> inside the
>> paintEvent for B, it only seems to work if B is positioned at
>> 0,0. If B is
>> moved with respect to its parent widget, the perspective
>> transform doesnt
>> work anymore, and it only does a translate/rotate/shear
>> rather than a proper
>> 2D perspective transform.
>>
>> Does anyone have any insight on why this is happening ?
>>
>> thanks.
>> -gaurav
>>
>
>--
>To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
>"unsubscribe" in the subject or the body.
>List archive and information: http://lists.trolltech.com/qt-interest/ 


--
 [ signature omitted ] 

Message 4 in thread

> I have attached the code that i am using to test this. If you 
> comment out 
> the #define, you will see the expected output of the 
> perspective transform.

Nicely stripped down code! :-)

Using Qt 4.3.1 i get no visual difference whether i define CHECK_BUG or
not. (Besides the obvious difference in size and placement).

Maybe you're using an older version? Seems this is fixed.

Cheers,
Peter

--
 [ signature omitted ] 

Message 5 in thread

Yup. i was using 4.3.0.  works with 4.3.1.

thanks,
-gaurav

> "Peter Prade" <prade@xxxxxxxxxxx> wrote in message 
> news:1C5B9B48EC79514FB4F4A7884ACFCB9F224580@xxxxxxxxxxxxxxxxxxxxxxx
>
> Nicely stripped down code! :-)
>
> Using Qt 4.3.1 i get no visual difference whether i define CHECK_BUG or
> not. (Besides the obvious difference in size and placement).
>
> Maybe you're using an older version? Seems this is fixed.
>
> Cheers,
> Peter
>
> --
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/ 


--
 [ signature omitted ]