Rotate QGraphicsProxyWidget in QGraphicsView
Hi,
I have a QPushButton on a QGraphicsProxyWidget. However when I rotate the proxy widget, the widget rotates but the rotation of the button is cannot be seen. Is it possible to rotate the QPushButton to appear rotated say at an angle of -20.
Code:
view.
setRenderHint(QPainter::Antialiasing);
QGraphicsProxyWidget *pw = scene.addWidget(wi);
pw->setPos(100, 100);
pw->setRotation(-20);
Any pointer would be of great help.
Thanks
Re: Rotate QGraphicsProxyWidget in QGraphicsView
Re: Rotate QGraphicsProxyWidget in QGraphicsView
Shouldn't you be using "btn" instead of "wi" in the call to scene.addWidget()?
Re: Rotate QGraphicsProxyWidget in QGraphicsView
Sorry I forgot to mention about the following. The wi is defined as follows
Code:
lay->addStretch();
wi->setLayout(lay);
scene.setSceneRect(0, 0, 500, 500);
view.
setRenderHint(QPainter::Antialiasing);
QGraphicsProxyWidget *pw = scene.addWidget(wi);
pw->setPos(100, 100);
pw->setRotation(-20);
Re: Rotate QGraphicsProxyWidget in QGraphicsView
Can you provide compilable example, because it is hard to understand what yo want to do. Once you are making a button and NOT adding it to any scene and you are rotating another widget which has nothing common with this button, so, as it can be expected, the button is not rotated... In you last post you have widget with button but it looks strange that you create scene and graphics view on a stack instead of heap, so where do you have this code? in main() function?
Re: Rotate QGraphicsProxyWidget in QGraphicsView
Yes the code is present in the main.
The problem faced is that the button rotates but the view of the button doesn't.
Re: Rotate QGraphicsProxyWidget in QGraphicsView
What do you mean by "the view of the button"? How about providing an image mockup of "what is" and "what should be"?
2 Attachment(s)
Re: Rotate QGraphicsProxyWidget in QGraphicsView
Attached what's happening ans what is required
Re: Rotate QGraphicsProxyWidget in QGraphicsView
And what about a complete code you used to obtain it? When I run my code, I get the required output :)
1 Attachment(s)
Re: Rotate QGraphicsProxyWidget in QGraphicsView
I just made my complete working code:
Code:
#include <QtCore>
#include <QtGui>
int main(int argc, char **argv)
{
gv.setScene(&scene);
gv.
setRenderHint(QPainter::Antialiasing);
lo.addWidget(&btn);
wi.setLayout(&lo);
QGraphicsProxyWidget *pw = scene.addWidget(&wi);
pw->setPos(0, 0);
pw->setRotation(-20);
gv.show();
return a.exec();
}
And what I get is on the screenshot. Am I missing something in my code?
EDIT:
The button is only displayed correctly when the Aero highlighting animation takes place on hover (when finished it is displayed wrong again)
Re: Rotate QGraphicsProxyWidget in QGraphicsView
What if you get rid of the "wi" widget and the layout? What if you call rotate() instead of setRotation()?
1 Attachment(s)
Re: Rotate QGraphicsProxyWidget in QGraphicsView
Code:
#include <QtCore>
#include <QtGui>
int main(int argc, char **argv)
{
gv.setScene(&scene);
gv.
setRenderHint(QPainter::Antialiasing);
QGraphicsProxyWidget *pw = scene.addWidget(&btn);
pw->setPos(0, 0);
pw->rotate(-20);
gv.show();
return a.exec();
}
gives:
Attachment 4113
Re: Rotate QGraphicsProxyWidget in QGraphicsView
Is there a solution to this problem ?
Re: Rotate QGraphicsProxyWidget in QGraphicsView
The solution is to use a widget style different than the native WindowsXP/Vista style. You may also browse the bug tracker to see if this bug was reported and fixed between 4.6.0 and 4.6.1. If so, you can download a patch and apply it to your 4.6.0 sources and rebuild the style. You may also downgrade to Qt 4.5.3
Re: Rotate QGraphicsProxyWidget in QGraphicsView