PDA

View Full Version : layout direction issues with QGraphicsScene



sanjayshelke
11th June 2009, 13:00
Hi All,
I have developed small application using graphics-view architecture.
I have created number of items using QGraphicsItem and added it to the scene.

Basically there is QMainWIndow which is having toolbars and its central widget is QGraphicsView.

Now my problem is for Right to Left languages the QMainWIndow layout direction changes properly such as for Arabic, Hebrew.

To change the layout direction of window, we need to install qt_ar.qm or qt_he.qm files in the application. I have done this and so minwindow layout is chnaged properly.

But the probelm is that the items i have added to the QGraphicsScene does not change according to layout.

e.g. A Table with 4 columns is created using QgraphicsItem. When layout is Right to Left, Table item should flipped so that its first column should be at right side.


Any solution to this.

Thanks in advance.

Regards,
~Sanjay

wysota
15th June 2009, 21:33
I don't think QGraphicsScene layouts support RTL languages by themselves. If you want to support them, detect an RTL language as usual and rebuild the layouts in the scene.

shentian
16th June 2009, 23:23
You could use QGraphicsView::scale to mirror the view and then mirror back all items, like:



QGraphicsView* view;
// ...
view->scale(-1, 0);
foreach (QGraphicsItem* item, view->items)
{
item->scale(-1, 0);
item->translate(-item->boundingRect().width(), 0);
}


This works quite well in one of my applications. Depending on how you use the scene's and items' coordinates (e.g. mouse events), you will need to make other changes too.