Results 1 to 3 of 3

Thread: layout direction issues with QGraphicsScene

  1. #1
    Join Date
    Jul 2007
    Posts
    90
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default layout direction issues with QGraphicsScene

    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

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,368
    Thanks
    3
    Thanked 5,018 Times in 4,794 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: layout direction issues with QGraphicsScene

    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.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. #3
    Join Date
    May 2009
    Posts
    62
    Thanks
    2
    Thanked 16 Times in 15 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: layout direction issues with QGraphicsScene

    You could use QGraphicsView::scale to mirror the view and then mirror back all items, like:

    Qt Code:
    1. // ...
    2. view->scale(-1, 0);
    3. foreach (QGraphicsItem* item, view->items)
    4. {
    5. item->scale(-1, 0);
    6. item->translate(-item->boundingRect().width(), 0);
    7. }
    To copy to clipboard, switch view to plain text mode 

    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.

Similar Threads

  1. How Coulld I create a Grid Layout on a QGraphicsScene
    By c_srikanth1984 in forum Qt Programming
    Replies: 3
    Last Post: 12th January 2009, 10:18
  2. Replies: 3
    Last Post: 4th April 2008, 19:51
  3. Qt layout memory issue
    By bunjee in forum Qt Programming
    Replies: 9
    Last Post: 25th August 2007, 17:11
  4. Layout Management Issues
    By dave in forum Newbie
    Replies: 3
    Last Post: 5th November 2006, 18:16
  5. Layout issues
    By vijay anandh in forum Qt Programming
    Replies: 2
    Last Post: 8th July 2006, 19:27

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.