QFileSystemModel is not working on Linux with QCompleter for ~username/....

  • I have used QFileSystemModel for QCompleter. On windows it works fine but on linux when I type ~gyeole/ it does not popup for auto completion. But if I type "/" then it pops up. Any suggestion to access directory with ~gyeole/....

  • Lifetime Qt Champion


    Can you share the code you are using for initialising Completer and the rest so it can be tested ?

  • QFileSystemModel *fModel = new QFileSystemModel();
    QObject::connect(m_dirCompleter, SIGNAL(activated(QString)),
    this, SLOT(insertCompletion(QString)));

    //m_dirCompleter is QCompleter

    //In QTextEdit in keyPressEvent captuaring edited text for poping up auto completion
    //getCompleter () returns m_dirCompleter
    getCompleter()->popup()->setCurrentIndex(getCompleter()->completionModel()->index(0, 0));
    cr = cursorRect();
    + getCompleter()->popup()->verticalScrollBar()->sizeHint().width());
    popupVisible = true;

    void CxConsoleQt::insertCompletion(const QString& string)
    std::string str = qPrintable(string);
    int extra = string.length() - getCompleter()->completionPrefix().length();
    m_editableLength += extra;

  • @Gitesh-Yeole
    Can you please use code tags as it makes it more readable?

  • Lifetime Qt Champion

    Note that the tilde handling in bash has nothing do to with path handling within a library, some will do the expansion for you under the hood but that's not something you should rely on for auto completion like that.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.