Commaseparated list with inline-completion with QLineEdit and QCompleter
Hello,
I'm currently developing a tagging-dialog for a media company using qt4 on their client software. The dialog has a QLineEdit where you is supposed to be able to enter a comma separated list of tags. A feature we have been looking to add to this is auto-completion of the tags.
This is the current code:
Code:
completer->setCaseSensitivity(Qt::CaseInsensitive);
completer
->setCompletionMode
(QCompleter::InlineCompletion);
ui.tagEdit->setCompleter(completer);
completer->setCompletionPrefix ( text.split(",").back().trimmed().toLower() );
It works ok for the first word, when you start writing on a empty line. But I also want it to work, as if it was a blank line, after a comma. ie. if you write "indie, roc" the last word should inline-complete to rock the sameway as if you only wrote "roc". Hope that make sens.
Re: Commaseparated list with inline-completion with QLineEdit and QCompleter
I have build
http://www.qt-apps.org/content/show....?content=59422
word completer from DB sqlite and grep word from text....
to insert comma separated word... replace Space and special sign by ##_## as example
and after iterate QTextDocument to replace the placeholder....
completer not like space...
Re: Commaseparated list with inline-completion with QLineEdit and QCompleter
Solved it. Thx :) If you want to see the result, download the Last.fm client v1.4 when it's released.
Re: Commaseparated list with inline-completion with QLineEdit and QCompleter
Here's a stupid simple solution. I like this one the best
http://john.nachtimwald.com/2009/07/...eparated-tags/
Re: Commaseparated list with inline-completion with QLineEdit and QCompleter
This also seems to do the job for the most part. When you actually do a completion it replaces the text in the line edit so more work might be needed or special handling on the line edit side would have to be implemented
Code:
def __init__(self, parent=None):
self.terms = []
def setTerms(self, terms):
self.model().setStringList(terms)
def splitPath(self, path):
raw_values = str(path).split(",")
values = [val.strip() for val in raw_values if val.strip()]
if len(raw_values) != len(values):
return [path]
return [values[-1]]