Results 1 to 5 of 5

Thread: QValidator for QGraphicsTextItem

  1. #1
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default QValidator for QGraphicsTextItem

    Hi all

    I have a QGraphicsTextItem that is editable. I want to assign a validator to it when I edit the contents. I know how to do it for a QLineEdit.

    can anyone guide me how to use it for QGraphicsTextItem?

    Thanks
    Arjun

  2. #2
    Join Date
    Feb 2006
    Location
    Romania
    Posts
    2,744
    Thanks
    8
    Thanked 541 Times in 521 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QValidator for QGraphicsTextItem

    There is no such default functionality in QGraphicsTexItem. But you can add it to it.
    You'll have to work directly with the QTextDocument provided by QGraphicsTextItem::textDocument().
    You can connect to QTextDocument::contentsChanged signal and do all the validation in there, either using a standard or costom QValidator.

    Regards

  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: QValidator for QGraphicsTextItem

    Even i do need such a functionality in my app but busy with something else at the moment. If you are able to achieve this, can you share your idea(or if possible code) please ?
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  4. #4
    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: QValidator for QGraphicsTextItem

    BTW currently i am validating text in the focusOutEvent() of the text item. I am not using any of QValidators for now.
    Sorry , forgot to post this in my previous post
    The biggest difference between time and space is that you can't reuse time.
    -- Merrick Furst

  5. #5
    Join Date
    Jul 2007
    Posts
    39
    Thanks
    10

    Default Re: QValidator for QGraphicsTextItem

    Sure. Once I have something I will post it.

    Arjun

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.