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. Regular Expression in QSortFilterProxyModel not working
Forum Updated to NodeBB v4.3 + New Features

Regular Expression in QSortFilterProxyModel not working

Scheduled Pinned Locked Moved Unsolved General and Desktop
5 Posts 3 Posters 659 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.
  • T Offline
    T Offline
    Thomas Stein
    wrote on last edited by Thomas Stein
    #1
    This post is deleted!
    JonBJ 1 Reply Last reply
    0
    • T Thomas Stein

      This post is deleted!

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #2

      @Thomas-Stein said in Regular Expression in QSortFilterProxyModel not working:

      proxyModel.setFilterRegExp("*.png")

      Looks like a file wildcard, not a reg exp. That demands literal * character. Don't you intend perhaps: ".*\\.png"?

      T 1 Reply Last reply
      0
      • JonBJ JonB

        @Thomas-Stein said in Regular Expression in QSortFilterProxyModel not working:

        proxyModel.setFilterRegExp("*.png")

        Looks like a file wildcard, not a reg exp. That demands literal * character. Don't you intend perhaps: ".*\\.png"?

        T Offline
        T Offline
        Thomas Stein
        wrote on last edited by Thomas Stein
        #3
        This post is deleted!
        1 Reply Last reply
        0
        • B Offline
          B Offline
          Bonnie
          wrote on last edited by Bonnie
          #4
          1. To solve the filter problem, you need to add proxyModel.setRecursiveFilteringEnabled(true).
            Otherwise you'll only filter the drivers.
          2. If you only want to filter with wildcard, simply use proxyModel.setFilterWildcard("*.png") instead of regular expression.
          3. The root index of view2 won't be at path, because proxyModel.mapFromSource(dirModel.index(path)) will return an invalid index.
            Maybe because path have not be loaded in dirModel yet?
            You can try to connect to the signal QFileSystemModel::directoryLoaded(const QString &path) and confirm path is loaded, then set the root index of view2
          T 1 Reply Last reply
          1
          • B Bonnie
            1. To solve the filter problem, you need to add proxyModel.setRecursiveFilteringEnabled(true).
              Otherwise you'll only filter the drivers.
            2. If you only want to filter with wildcard, simply use proxyModel.setFilterWildcard("*.png") instead of regular expression.
            3. The root index of view2 won't be at path, because proxyModel.mapFromSource(dirModel.index(path)) will return an invalid index.
              Maybe because path have not be loaded in dirModel yet?
              You can try to connect to the signal QFileSystemModel::directoryLoaded(const QString &path) and confirm path is loaded, then set the root index of view2
            T Offline
            T Offline
            Thomas Stein
            wrote on last edited by Thomas Stein
            #5
            This post is deleted!
            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