Results 1 to 10 of 10

Thread: how can I make a balloon to wrap the editable text?

  1. #1
    Join Date
    Sep 2008
    Posts
    93
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default how can I make a balloon to wrap the editable text?

    I hope to add some editable texts wrapped by a balloon in QGraphicsScene.

    1. Which QT class will be the class to make this balloon and balloon's shape can be changed ?
    2. I also hope to insert this balloon to QGraphicsScene with the specified position, how can I do?

    Thanks!

  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: how can I make a balloon to wrap the editable text?

    Quote Originally Posted by learning_qt View Post
    1. Which QT class will be the class to make this balloon and balloon's shape can be changed ?
    QGraphicsPathItem or QGraphicsRectItem, depending on what you want to achieve.

    You will also have to create a QGraphicsTextItem as a child of that item to have editable text inside the baloon.

    2. I also hope to insert this balloon to QGraphicsScene with the specified position, how can I do?
    Use QGraphicsItem::setPos().

  3. #3
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how can I make a balloon to wrap the editable text?

    There was a related shaped text example in Qt Quarterly(qq24 i guess). You can search for it.

  4. #4
    Join Date
    Sep 2008
    Posts
    93
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: how can I make a balloon to wrap the editable text?

    Hello wysota

    I am not clear about your idea.
    You will also have to create a QGraphicsTextItem as a child of that item to have editable text inside the baloon.
    I will use QLineEdit to edit the text. It is a QWidget.

    How can I create a QGraphicsTextItem as a child from the QLineEdit?

    Could you please give some code example?

    Thanks!

  5. #5
    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: how can I make a balloon to wrap the editable text?

    Why do you want to put a QLineEdit inside a graphics scene?

  6. #6
    Join Date
    Sep 2008
    Posts
    93
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: how can I make a balloon to wrap the editable text?

    I hope to input some texts to the image. And those texts can be editable.

    The idea is like this:

    I insert one QImage in QGraphicsScene.
    I hope to add some text to this QGraphicsScene, for example, "It is taken in Norway". And those texts can be edited.
    After saving, the texts and image will be merged.

    Thanks!

  7. #7
    Join Date
    Oct 2006
    Location
    New Delhi, India
    Posts
    2,467
    Thanks
    8
    Thanked 334 Times in 317 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: how can I make a balloon to wrap the editable text?

    You can edit text in QGraphicsTextItem.
    Have a look at Diagram Scene example in Qt Demo-->GraphicsView section

  8. #8
    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: how can I make a balloon to wrap the editable text?

    But you don't need a QLineEdit for that Use QGraphicsTextItem as suggested.

  9. #9
    Join Date
    Sep 2008
    Posts
    93
    Thanks
    6
    Thanked 1 Time in 1 Post

    Default Re: how can I make a balloon to wrap the editable text?

    Thanks!

    I started to use QGraphicsTextItemBut I still can not add one editable area to QGraphicsScene
    i did like this. I am sure there are something missing, but I don't know what?

    Qt Code:
    1. textItem->setTextInteractionFlags(Qt::TextEditorInteraction);
    2. textItem->setZValue(1000.0);
    3. imageScene->addItem(textItem);
    4. textItem->setPos(200,300);
    To copy to clipboard, switch view to plain text mode 

  10. #10
    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: how can I make a balloon to wrap the editable text?

    You are missing an asterisk in the declaration of the item. Also set the ItemIsFocusable flag on the item.

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Editable text in QGraphicsView
    By wysota in forum Qt Programming
    Replies: 8
    Last Post: 24th February 2007, 15:30
  3. Compiling with Qmake/Make
    By VireX in forum Newbie
    Replies: 25
    Last Post: 22nd February 2007, 05:57

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.