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 - Customise Features of Setting ReadOnly(false)
QtWS25 Last Chance

QFileSystemModel - Customise Features of Setting ReadOnly(false)

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

    Hey Again,

    Another small query,

    When we set the qfilesystemmodel to not be readonly ( to get drag-drop, rename..) is there anyway to turn a particular feature off?

    My main reason for asking this is that the double click tries to edit the filename, I do not want that action since I have a slot to open the file on double click. So with both together its like a nasty flicker on item(entering edit and exiting) on double click and file opens.

    I'd like the rename function that the default double click gives itself but say from a customcontextmenu or something.

    Looking at the data() function for qfilesystemmodel I'm not sure if we can have one without the other

    @
    flags |= Qt::ItemIsDragEnabled;
    if (d->readOnly)
    return flags;
    if ((index.column() == 0) && indexNode->permissions() & QFile::WriteUser) {
    flags |= Qt::ItemIsEditable;
    if (indexNode->isDir())
    flags |= Qt::ItemIsDropEnabled;
    }
    return flags;
    @

    Would be nice if i could just disable the annoying edit on double click.

    Also how does the default model set the item in a editing state btw(provided it has a flag set for Qt::ItemIsEditable)?

    1 Reply Last reply
    0
    • N Offline
      N Offline
      Nosf
      wrote on last edited by
      #2

      Forgot to post a reply, but I solved this eventually myself.

      The flicker is due to QTreeView and its edit function being tied to a double click. Hence I just Subclassed QTreeView with

      @
      bool DerivedTreeView::edit(const QModelIndex& index,
      EditTrigger trigger,
      QEvent* event) {
      if (trigger == QAbstractItemView::DoubleClicked)
      return false;
      return QTreeView::edit(index, trigger, event);
      }
      @

      ^^ That just ignores the edit call when the trigger is a double click and hence the flicker is gone. Also by using the same edit function from the context menu I could get the rename functionality as well when needed.

      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