PDA

View Full Version : QCompleter extract from Assistant



patrik08
23rd May 2007, 09:02
If you say a way to extract a QStringList words from class to insert on QCompleter?
or interact from assistant search on a model?

wysota
23rd May 2007, 10:42
Could you rephrase your question? I have difficulties understanding what your question means.

patrik08
23rd May 2007, 11:21
Could you rephrase your question? I have difficulties understanding what your question means.

My question is only how to extract QT4 class name on a qstringlist to add on a QCompleter?
Or cast direct from assistant... is here a way?





TextEdit::TextEdit(QWidget *parent)
: QTextEdit(parent), c(0)
{
highlighter = new Highlighter(document()); /* Highlighter *highlighter; */
completerbase = new QCompleter();
completerbase->setModel(modelFromFile(":img/qtclass.txt"));
completerbase->setModelSorting(QCompleter::CaseInsensitivelySorte dModel);
completerbase->setCaseSensitivity(Qt::CaseInsensitive);
completerbase->setWrapAround(false);
setCompleter(completerbase);

}

wysota
23rd May 2007, 11:55
Extract from assistant? Assistant saves its index in a file that's probably in your $HOME/.assistant/. I don't know the format, but it should be easy to retrieve it by looking at assistant source code.

patrik08
23rd May 2007, 13:14
Extract from assistant? Assistant saves its index in a file that's probably in your $HOME/.assistant/. I don't know the format, but it should be easy to retrieve it by looking at assistant source code.


I tidy to xml the file http://doc.trolltech.com/4.3/functions.html :)




QString errorStr, obname;
int errorLine, errorColumn;
QDomDocument doc;
QFile f("function.xml");
if (!doc.setContent(&f,false, &errorStr, &errorLine, &errorColumn)) {
return 0;
}

int sumfunction = 0;

QDomElement root = doc.documentElement();
QDomElement group = root.firstChildElement("ul");
QDomElement listing = group.firstChildElement("li");
while (!listing.isNull()) {
QDomElement pagelink = listing.firstChildElement("a");
obname = pagelink.firstChildElement("span").text();
if (obname !="") {
sumfunction++;
std::cout << sumfunction << ") qtfu: ->" << qPrintable(obname) << std::endl;
}
listing = listing.nextSiblingElement("li");
}

/* summfunction qt4 rc1 6028.. */