Results 1 to 4 of 4

Thread: Creating a tag/keyword entry widget using a line edit

  1. #1
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Question Creating a tag/keyword entry widget using a line edit

    I want to create a widget for entering and editing tags. Flickr has a similar interface, but I'd like to take it one step further.

    I'd like to create something like this:
    taglineedit.png

    I have comma separated auto-complete working using a QCompleter (see http://www.qtcentre.org/threads/8098...and-QCompleter)

    The idea is the user enters a tag followed by a comma, or by hitting enter, this in turn would create on of those blue tag bubbles. You can click on the 'x' in the tag to delete it, or select it and delete it. I'm looking for some good ideas on how to create such a widget. It seems rather hard to do just by customizing a QLineEdit. I thought I'd address the collective genius of QtCentre for any ideas.

    FYI: I tried overloading the paint method on a QLineEdit and was able to draw the individual tag widgets but then I wasn't able to draw the rest of the line edit correctly, ie the blinking cursor, selected/deselected text etc.

  2. #2
    Join Date
    Jul 2009
    Posts
    74
    Thanks
    2
    Thanked 6 Times in 6 Posts

    Default Re: Creating a tag/keyword entry widget using a line edit

    seems very difficult onlywith painting...


    but... maybe this idea could help you:

    create a "bubble" widget

    and after that...
    create another widget (qtaglineedit -> not subclassing qlineedit!! is a new composition widget):
    A Frame with white background...(to simulate a line edit)
    inside the frame an empty "Widget" (in the left) and a qlineedit (in the right)... vertical layout ...

    when you write a tag... you create a bubble... and add that bubble in the empty widget. of the left...
    and so on...


    I hope it helps

  3. #3
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default Re: Creating a tag/keyword entry widget using a line edit

    Not a bad idea. Even better, I could create 3 widgets. The main widget would be a container widget that draws its frame the same as a line/text edit. Add a flow layout to that widget, then the first widget in the flow layout be the bubble widget, drawing the bubbles, it could also be a bubble container, then the next widget in the flow layout could be a line edit with no frame.

    To make it feel right I think the line edit will have to grow/shrink based on the size of the text the user is typing, so that when you get near the end of the line (the edge of the dialog), the flow layout will drop the line edit to the next line and the tag line edit will start to look more like a text edit. The only play where this might not feel right is a tag with spaces in it, but I think thats ok.

    One of the hard things about the bubbles was trying to get them to scroll if necessary, if the main widget is a scroll area that might make things easier.

    I was hoping I could somehow just do this with a text edit and some fancy wizardry but this could work. Thanks

  4. #4
    Join Date
    Jun 2008
    Posts
    88
    Thanks
    4
    Thanked 4 Times in 3 Posts
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11
    Wiki edits
    1

    Default Re: Creating a tag/keyword entry widget using a line edit

    Theres some more gems on this in this post: http://www.qtcentre.org/threads/3780...442#post174442

Similar Threads

  1. QTableView line edit clears the text on edit
    By PlasticJesus in forum Qt Programming
    Replies: 5
    Last Post: 14th March 2015, 19:06
  2. Inline keyword doubt and... exist outline keyword ?
    By tonnot in forum General Programming
    Replies: 4
    Last Post: 23rd September 2010, 23:51
  3. Replies: 3
    Last Post: 26th August 2010, 08:57
  4. how to access LINE EDIT'S value
    By BalaQT in forum Qt Programming
    Replies: 8
    Last Post: 20th August 2009, 10:58
  5. Replies: 8
    Last Post: 15th May 2007, 09:21

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.