Results 1 to 5 of 5

Thread: Manipulate QGraphicsTextItems on a QGraphicsScene

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Manipulate QGraphicsTextItems on a QGraphicsScene

    Hello everyone,

    I wanted to create a program for taking notes which is based on QGraphicsTextItems, I wanted to have behavior that is different from the QtTextItem which is added to a QGraphicsScene. The problem is, that for this behavior I've to change the TextItems (editable / not editable) when somewhere on the scene a click happens . The Problem is, that I can't call this functions because all the stuff which is added on the scene are just QGraphicsItems and they don't have this behavior (editable / non editable etc.).
    I tried to make a list with all the QGraphicsTextItems so i could reset all of them. I couldn't find a better solution... is there another way of doing this? I thought my way isn't really object-oriented...

    the program works fine but I think it's a bit inefficient

    Thank you for your suggestions & help

    airglide

  2. #2
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Manipulate QGraphicsTextItems on a QGraphicsScene

    if those items don't have that (editable) behaviour, shouldn't you be adding it to your own 'TextItems'? You can also use QGraphicsObject if you need signals/slots.
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  3. #3
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Manipulate QGraphicsTextItems on a QGraphicsScene

    The QGraphicsTextItem have this behavior (TextInteraction editable/non editable). If I have a QGraphicsScene there are only items and I don't know how I can get the behavior of the QGraphicsTextItem.

  4. #4
    Join Date
    Sep 2011
    Posts
    1,241
    Thanks
    3
    Thanked 127 Times in 126 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Manipulate QGraphicsTextItems on a QGraphicsScene

    you can do as you are (if I understand correctly) and keep your own list of QGraphicsTextItem*, or you can just use dynamic_cast or qobject_cast to check if QGraphicsItem is also a QGraphicsTextItem
    If you have a problem, CUT and PASTE your code. Do not retype or simplify it. Give a COMPLETE and COMPILABLE example of your problem. Otherwise we are all guessing the problem from a fabrication where relevant details are often missing.

  5. The following user says thank you to amleto for this useful post:

    airglide (28th July 2012)

  6. #5
    Join Date
    Jul 2012
    Location
    Switzerland
    Posts
    32
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Manipulate QGraphicsTextItems on a QGraphicsScene

    great I'll have a look at qobject_cast

    thanks

Similar Threads

  1. how to manipulate a very large data using QT?
    By aurora in forum Qt Programming
    Replies: 10
    Last Post: 25th May 2012, 17:37
  2. PyQt: How to manipulate QFileDialog
    By xaverxn in forum Newbie
    Replies: 1
    Last Post: 28th October 2010, 20:58
  3. How to manipulate a thread
    By avis_phoenix in forum Newbie
    Replies: 1
    Last Post: 18th August 2008, 23:34
  4. how to manipulate the keyboard event?
    By Ricardo_arg in forum Qt Programming
    Replies: 2
    Last Post: 4th August 2008, 07:49
  5. [java] manipulate a string
    By mickey in forum General Programming
    Replies: 5
    Last Post: 10th July 2008, 20:22

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.