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. QProxyModel/SortModel display items without children ?

QProxyModel/SortModel display items without children ?

Scheduled Pinned Locked Moved Solved General and Desktop
qsortfilterproxqstandarditemmqproxymodel
7 Posts 2 Posters 672 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.
  • D Offline
    D Offline
    Dariusz
    wrote on 27 May 2022, 16:07 last edited by
    #1

    Hey

    Say I have a item model with this hierarchy:

    >item
        >item2
           >item3  
              >item4
    

    Which model should I use to display it as

    item
    item2
    item3  
    item4
    

    So no children, all linearly top to bottom.

    As well as then display only ones matching specific string...
    Would a QSortFilterProxyModel work for both of my needs or do I have to daisy chain 2 together? QProxyModel + SortFilter?

    Regards
    Dariusz

    1 Reply Last reply
    0
    • V Offline
      V Offline
      VRonin
      wrote on 27 May 2022, 17:04 last edited by
      #6

      @Dariusz said in QProxyModel/SortModel display items without children ?:

      How on earth do I get it

      Open a developer command prompt with cmake and git and run:
      (This is for Windows on MSVC, for MinGW replace NMake with MinGW. for linux/mac just remove -G"NMake Makefiles")

      git clone https://invent.kde.org/frameworks/extra-cmake-modules.git
      cd extra-cmake-modules
      mkdir build
      cd build
      cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
      cmake --build . --target install
      cd ../../
      git clone https://invent.kde.org/frameworks/kitemmodels.git
      cd kitemmodels
      mkdir build
      cd build
      cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_PREFIX_PATH="../../KDEAPI" -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
      cmake --build . --target install
      cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_PREFIX_PATH="../../KDEAPI" -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
      cmake --build . --target install
      cd ../../
      rmdir extra-cmake-modules /s /q
      rmdir kitemmodels /s /q
      

      Now just add the path to the newly created KDEAPI folder to the CMAKE_PREFIX_PATH of your project in the project configuration

      "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
      ~Napoleon Bonaparte

      On a crusade to banish setIndexWidget() from the holy land of Qt

      D 1 Reply Last reply 28 May 2022, 09:22
      2
      • V Offline
        V Offline
        VRonin
        wrote on 27 May 2022, 16:18 last edited by VRonin
        #2

        Which model should I use to display it as

        KDescendantsProxyModel from KItemModels https://api.kde.org/frameworks/kitemmodels/html/classKDescendantsProxyModel.html

        do I have to daisy chain 2 together? QProxyModel + SortFilter?

        Chain away!

        "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
        ~Napoleon Bonaparte

        On a crusade to banish setIndexWidget() from the holy land of Qt

        D 1 Reply Last reply 27 May 2022, 16:19
        2
        • V VRonin
          27 May 2022, 16:18

          Which model should I use to display it as

          KDescendantsProxyModel from KItemModels https://api.kde.org/frameworks/kitemmodels/html/classKDescendantsProxyModel.html

          do I have to daisy chain 2 together? QProxyModel + SortFilter?

          Chain away!

          D Offline
          D Offline
          Dariusz
          wrote on 27 May 2022, 16:19 last edited by
          #3

          @VRonin WOaaa KDescendantsProxyModel looks epic but... How on earth do I get it O.O

          V 1 Reply Last reply 27 May 2022, 16:21
          0
          • D Dariusz
            27 May 2022, 16:19

            @VRonin WOaaa KDescendantsProxyModel looks epic but... How on earth do I get it O.O

            V Offline
            V Offline
            VRonin
            wrote on 27 May 2022, 16:21 last edited by
            #4

            @Dariusz

            • What do you use as build system? (CMake/qmake/qbs/etc.)
            • What OS are you on?

            "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
            ~Napoleon Bonaparte

            On a crusade to banish setIndexWidget() from the holy land of Qt

            D 1 Reply Last reply 27 May 2022, 16:22
            0
            • V VRonin
              27 May 2022, 16:21

              @Dariusz

              • What do you use as build system? (CMake/qmake/qbs/etc.)
              • What OS are you on?
              D Offline
              D Offline
              Dariusz
              wrote on 27 May 2022, 16:22 last edited by
              #5

              @VRonin Hey
              Cmake/ all platforms.

              I think I'm good, I can just "borrow" the 2 classes from > https://invent.kde.org/frameworks/kitemmodels/-/tree/master/src/core o.O
              EPIC !
              I need to dig more in to that website, thats awesome o.o

              1 Reply Last reply
              0
              • V Offline
                V Offline
                VRonin
                wrote on 27 May 2022, 17:04 last edited by
                #6

                @Dariusz said in QProxyModel/SortModel display items without children ?:

                How on earth do I get it

                Open a developer command prompt with cmake and git and run:
                (This is for Windows on MSVC, for MinGW replace NMake with MinGW. for linux/mac just remove -G"NMake Makefiles")

                git clone https://invent.kde.org/frameworks/extra-cmake-modules.git
                cd extra-cmake-modules
                mkdir build
                cd build
                cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
                cmake --build . --target install
                cd ../../
                git clone https://invent.kde.org/frameworks/kitemmodels.git
                cd kitemmodels
                mkdir build
                cd build
                cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_PREFIX_PATH="../../KDEAPI" -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
                cmake --build . --target install
                cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_PREFIX_PATH="../../KDEAPI" -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
                cmake --build . --target install
                cd ../../
                rmdir extra-cmake-modules /s /q
                rmdir kitemmodels /s /q
                

                Now just add the path to the newly created KDEAPI folder to the CMAKE_PREFIX_PATH of your project in the project configuration

                "La mort n'est rien, mais vivre vaincu et sans gloire, c'est mourir tous les jours"
                ~Napoleon Bonaparte

                On a crusade to banish setIndexWidget() from the holy land of Qt

                D 1 Reply Last reply 28 May 2022, 09:22
                2
                • V VRonin
                  27 May 2022, 17:04

                  @Dariusz said in QProxyModel/SortModel display items without children ?:

                  How on earth do I get it

                  Open a developer command prompt with cmake and git and run:
                  (This is for Windows on MSVC, for MinGW replace NMake with MinGW. for linux/mac just remove -G"NMake Makefiles")

                  git clone https://invent.kde.org/frameworks/extra-cmake-modules.git
                  cd extra-cmake-modules
                  mkdir build
                  cd build
                  cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
                  cmake --build . --target install
                  cd ../../
                  git clone https://invent.kde.org/frameworks/kitemmodels.git
                  cd kitemmodels
                  mkdir build
                  cd build
                  cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_PREFIX_PATH="../../KDEAPI" -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
                  cmake --build . --target install
                  cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=DEBUG -DCMAKE_PREFIX_PATH="../../KDEAPI" -DCMAKE_INSTALL_PREFIX="../../KDEAPI" ../
                  cmake --build . --target install
                  cd ../../
                  rmdir extra-cmake-modules /s /q
                  rmdir kitemmodels /s /q
                  

                  Now just add the path to the newly created KDEAPI folder to the CMAKE_PREFIX_PATH of your project in the project configuration

                  D Offline
                  D Offline
                  Dariusz
                  wrote on 28 May 2022, 09:22 last edited by Dariusz
                  #7

                  @VRonin Awesome thanks! I was able tho to just grab the 2 files and use them directly so yay!

                  This tree model is epic. It does 90% of what I wanted ! Now I just gotta figure out how to hide parent/groups, so I only see items, but that should be fine, super awesome, thanks!

                  Edit1. using sort filter model later to decide if I want to show parents/etc worked just fine, yay!

                  1 Reply Last reply
                  0

                  4/7

                  27 May 2022, 16:21

                  • Login

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