Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QFileSystemModel is not working on Linux with QCompleter for ~username/....

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

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 1.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Gitesh YeoleG Offline
    Gitesh YeoleG Offline
    Gitesh Yeole
    wrote on last edited by
    #1

    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/....

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

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

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • Gitesh YeoleG Offline
        Gitesh YeoleG Offline
        Gitesh Yeole
        wrote on last edited by
        #3

        QFileSystemModel *fModel = new QFileSystemModel();
        fModel->setRootPath("");
        m_dirCompleter->setModel(fModel);
        m_dirCompleter->setCompletionMode(QCompleter::PopupCompletion);
        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()->setCompletionPrefix(str1);
        getCompleter()->popup()->setCurrentIndex(getCompleter()->completionModel()->index(0, 0));
        cr = cursorRect();
        cr.setWidth(getCompleter()->popup()->sizeHintForColumn(0)
        + getCompleter()->popup()->verticalScrollBar()->sizeHint().width());
        getCompleter()->complete(cr);
        popupVisible = true;

        void CxConsoleQt::insertCompletion(const QString& string)
        {
        std::string str = qPrintable(string);
        int extra = string.length() - getCompleter()->completionPrefix().length();
        m_inputCursor.insertText(string.right(extra));
        this->setTextCursor(m_inputCursor);
        m_editableLength += extra;
        }

        the_T 1 Reply Last reply
        0
        • Gitesh YeoleG Gitesh Yeole

          QFileSystemModel *fModel = new QFileSystemModel();
          fModel->setRootPath("");
          m_dirCompleter->setModel(fModel);
          m_dirCompleter->setCompletionMode(QCompleter::PopupCompletion);
          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()->setCompletionPrefix(str1);
          getCompleter()->popup()->setCurrentIndex(getCompleter()->completionModel()->index(0, 0));
          cr = cursorRect();
          cr.setWidth(getCompleter()->popup()->sizeHintForColumn(0)
          + getCompleter()->popup()->verticalScrollBar()->sizeHint().width());
          getCompleter()->complete(cr);
          popupVisible = true;

          void CxConsoleQt::insertCompletion(const QString& string)
          {
          std::string str = qPrintable(string);
          int extra = string.length() - getCompleter()->completionPrefix().length();
          m_inputCursor.insertText(string.right(extra));
          this->setTextCursor(m_inputCursor);
          m_editableLength += extra;
          }

          the_T Offline
          the_T Offline
          the_
          wrote on last edited by
          #4

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

          -- No support in PM --

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            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.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            1

            • Login

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • Users
            • Groups
            • Search
            • Get Qt Extensions
            • Unsolved