Results 1 to 6 of 6

Thread: QGraphicsView problem

  1. #1
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default QGraphicsView problem

    Hi everyone, i am working on an app that reads data from a database and displays the data on a QGraphicsRectItem (at least that is whats the app is suppose to do). My problem is that i am clueless as to how to implement the above. I am able to add a simple rectangular item in the QGraphacsView using QGraphicsRectItem and QGraphicsScene but beyond that i am clueless. I have read the Qt documentation but there is not enough information for me to realize my goal or maybe i'm just not understanding the Qt documentation. OK, NOW THIS IS WHAT I WANT TO ACHIEVE, the app must read a person's name and surname from the database and then display that information in a rectangular item in the GraphicsView. The rect item must be aligned to the top left-hand corner of the GraphicsView and scaling the whole width of the GraphicsView and only 10mm in height. If an extra name and surname is read from the database another identical rectItem is to be created and placed below the previous one, hence forming some kind of an array like structure. NB: When GraphicsView is scaled up, down, left or right the rectItems are to scale with the graphicsView. I DON'T EXPECT SOMEBODY TO RIGHT THE CODE FOR ME but i would appreciate it if somebody can tell me which Class objects I can use for all the above. THANKING YOU IN ADVANCE.

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView problem

    Which parts other then creating the rectangle have you tried already?

    The part where you get data from the database sounds completely solvable stand alone, i.e. can be tested without GUI or with simple widget GUI, see QSqlQuery

    The visualization can also be implemented and tested without the database access, see QGraphicsItem and subclasses

    Cheers,
    _

  3. #3
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView problem

    thank you for your reply anda_skoa, reading data from the database is not a problem, the problem is creating the rectangles.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView problem

    You write that you already managed to create a rectangle item and add it to the scene.
    So what kind of problem do you have with it?

    Cheers,
    _

  5. #5
    Join Date
    Jul 2012
    Posts
    201
    Thanks
    26
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QGraphicsView problem

    the problem i have is aligning the rectangle item to the top left-hand corner of the GraphicsView and then make the rectangles item's length be the same size as the GraphicsView's length size.

  6. #6
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: QGraphicsView problem

    QGraphicsView::mapToScene() methods should help you with that.

    Cheers,
    _

Similar Threads

  1. QGraphicsView problem
    By sourena in forum Newbie
    Replies: 2
    Last Post: 5th August 2012, 05:45
  2. QGraphicsView Problem
    By Toaders in forum Newbie
    Replies: 1
    Last Post: 15th May 2009, 18:48
  3. QGraphicsView Problem
    By hakkman in forum Qt Programming
    Replies: 2
    Last Post: 14th June 2008, 20:27
  4. QGraphicsView Problem !!
    By Gamalof in forum Qt Programming
    Replies: 3
    Last Post: 14th June 2008, 13:55
  5. Problem with QGraphicsView.
    By kiranraj in forum Qt Programming
    Replies: 1
    Last Post: 4th July 2007, 19:44

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.