Results 1 to 5 of 5

Thread: Propery capable QGraphicsTextItem

  1. #1
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Propery capable QGraphicsTextItem

    Hi,
    I need a way to display properties of a component which are editable. For eg for resistor's property resistance -
    R = 10k
    What I want is the text only after '=' to be editable not before it. That is, '10k' should be alterable not 'R'. Currently I have implemented this using two QGraphicsTextItem and making one part editable but this is performance blow since it increases the number of items to be moved while many components are moved.

    I feel this can be done in better faster way. I'd be glad if anyone can help me on how I can do that.
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

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

    Default Re: Propery capable QGraphicsTextItem

    You can subclass the item and reimplement the paint method, calling the base class with a modified painter rectangle (translate the painter). As for the "static" part, draw it on the painter yourself.

  3. #3
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Propery capable QGraphicsTextItem

    Quote Originally Posted by wysota View Post
    You can subclass the item and reimplement the paint method, calling the base class with a modified painter rectangle (translate the painter). As for the "static" part, draw it on the painter yourself.
    But what about managing bounding rect ? Can you please help me ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

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

    Default Re: Propery capable QGraphicsTextItem

    What about the rect? You have to modify it to include the "static" part. You'll probably want to use QFontMetrics to calculate the size needed.

  5. #5
    Join Date
    Aug 2006
    Location
    Bangalore,India
    Posts
    419
    Thanks
    37
    Thanked 53 Times in 40 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Propery capable QGraphicsTextItem

    Quote Originally Posted by wysota View Post
    What about the rect? You have to modify it to include the "static" part. You'll probably want to use QFontMetrics to calculate the size needed.
    Ok I will do that. But for testing purpose I used magic numbers. I am attaching the code.
    The problem now is I am not able to move the item normally. Whats wrong ?
    Attached Files Attached Files
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

Similar Threads

  1. QGraphicsTextItem: handling cursor position change
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2007, 10:42
  2. QGraphicsTextItem size
    By Angelo Moriconi in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2007, 08:34
  3. QGraphicsTextItem - is it a bug there?
    By Tair in forum Qt Programming
    Replies: 5
    Last Post: 18th October 2006, 08:48

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.