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. Help using QCompleter with QFileSystemModel
Forum Updated to NodeBB v4.3 + New Features

Help using QCompleter with QFileSystemModel

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.6k Views 1 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.
  • E Offline
    E Offline
    EvanED
    wrote on last edited by
    #1

    I want to adapt the 'customcompleter' example (http://doc.qt.digia.com/qt/tools-customcompleter.html) to use a file system completer instead of reading out of the word list.

    The docs say you can use a QFileSystemModel using the following (http://doc.qt.digia.com/qt/qcompleter.html):

    @ QCompleter *completer = new QCompleter(this);
    completer->setModel(new QDirModel(completer));
    lineEdit->setCompleter(completer);
    @

    [Typo, btw.] So in the example, I tried changing:

    @ completer->setModel(modelFromFile(":/resources/wordlist.txt"));@

    to

    @ QFileSystemModel * model = new QFileSystemModel(completer);
    model->setRootPath("");
    completer->setModel(model);
    @

    (I also tried it without the setRootPath call, passing in "." and "/", and with QDirModel instead.)

    It no longer works: the completion window does not appear either on its own or when called with ctrl-E. What am I doing wrong?

    1 Reply Last reply
    0
    • E Offline
      E Offline
      EvanED
      wrote on last edited by
      #2

      Oh, I guess I should say that I'm using Qt 4.8.1 on Linux.

      1 Reply Last reply
      0

      • Login

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