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. Suitable "editable list" widget?
QtWS25 Last Chance

Suitable "editable list" widget?

Scheduled Pinned Locked Moved Solved General and Desktop
14 Posts 5 Posters 4.7k 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.
  • S SGaist
    22 Nov 2018, 13:54

    Hi,

    The usual thing to do (and you can find that for example in macOS's interface) is to have a + and - buttons at the bottom or the top of your QTableWidget/View to add/remove element. The - button being only enabled when something is selected.

    Do you mean you want the "Select" text on your button or have a hint with ... on the second column ?

    J Offline
    J Offline
    JonB
    wrote on 22 Nov 2018, 14:07 last edited by
    #5

    @SGaist
    Thanks, that's closer. Rushing out now, will answer later on....

    1 Reply Last reply
    0
    • S SGaist
      22 Nov 2018, 13:54

      Hi,

      The usual thing to do (and you can find that for example in macOS's interface) is to have a + and - buttons at the bottom or the top of your QTableWidget/View to add/remove element. The - button being only enabled when something is selected.

      Do you mean you want the "Select" text on your button or have a hint with ... on the second column ?

      J Offline
      J Offline
      JonB
      wrote on 22 Nov 2018, 16:41 last edited by
      #6

      @SGaist

      • OK, the way you approach it is to have just one table-wide button to do something, and rely on a current item being selected by the user. My way (inherited from ASP.NET) is not to have a selection and instead have necessary buttons on each row. I didn't think of yours. If that's more usual, and it sounds simpler, I'll do it that way. Also if I won't need columns for buttons, I could just have a simple QListWidget instead of a QTableView since I only have one data item cell, sounds good!

      • For the "selection" case. Instead of just typing into the data cell, the user needs something to click to take him to a dialog. I don't much care what that is. I was thinking of a ... button say to the right of each cell. But that will introduce a new column/widget, it won't be so easy to just do as QListWidget, and I don't know if QTableView allows columns just for widgets instead of the data. However, your new way I could just add one ... button, like one add and one delete, at table-level to use on whatever row is selected, which would solve.

      My one reservation is user having to understand that buttons for doing stuff on whatever is selected are at top/bottom. It saves on space, but it doesn't seem so immediately intuitive to me as having the buttons on each row. I don't use mobiles/Apples :) Is that a good way to do it? Anyone have a screenshot of what it looks like on some device? :)

      K 1 Reply Last reply 23 Nov 2018, 02:26
      0
      • V Offline
        V Offline
        VRonin
        wrote on 22 Nov 2018, 17:11 last edited by VRonin
        #7

        For an intuitive insertion-at-bottom interface you can have a look at this library using Insert Proxy Model (I'm trying to also get this proxy included in Qt 5.13). You can find example usage here

        for the remove/edit buttons you can use KExtraColumnsProxyModel from the KDE library (that module works on all platforms). You just need to return a pixmap as Qt::DecorationRole for the extraColumnData() and connect the clicked signal of the view to a slot that deletes the row or changes the flags() of the model to make it editable.

        Basically:
        source model -> KExtraColumnsProxyModel -> InsertProxyModel -> view

        or
        source model -> KExtraColumnsProxyModel -> view
        if you want the insert button as you have the edit and delete ones

        "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

        J 1 Reply Last reply 22 Nov 2018, 17:23
        3
        • V VRonin
          22 Nov 2018, 17:11

          For an intuitive insertion-at-bottom interface you can have a look at this library using Insert Proxy Model (I'm trying to also get this proxy included in Qt 5.13). You can find example usage here

          for the remove/edit buttons you can use KExtraColumnsProxyModel from the KDE library (that module works on all platforms). You just need to return a pixmap as Qt::DecorationRole for the extraColumnData() and connect the clicked signal of the view to a slot that deletes the row or changes the flags() of the model to make it editable.

          Basically:
          source model -> KExtraColumnsProxyModel -> InsertProxyModel -> view

          or
          source model -> KExtraColumnsProxyModel -> view
          if you want the insert button as you have the edit and delete ones

          J Offline
          J Offline
          JonB
          wrote on 22 Nov 2018, 17:23 last edited by JonB
          #8

          @VRonin
          Thank you for your detailed answer. In my case I did say I don't want to have to bring in new libraries, like the KDE one. Remember I'm also Python/PyQt, makes life much harder. I realise that's my choice.

          I think I can roll my own adequately if I follow @SGaist's interface, and use row selection with a table-level button acting on it. Avoid columns and do the whole thing as a QListWidget hopefully.

          Yours is probably closest to what I am used to. (And I have noticed that KDE seems to be what offers the "extra stuff you can do with columns" etc. I am used to compared to Qt's in-builts.) But it breaks my "minimal code" desire, no offence intended!

          1 Reply Last reply
          0
          • J JonB
            22 Nov 2018, 16:41

            @SGaist

            • OK, the way you approach it is to have just one table-wide button to do something, and rely on a current item being selected by the user. My way (inherited from ASP.NET) is not to have a selection and instead have necessary buttons on each row. I didn't think of yours. If that's more usual, and it sounds simpler, I'll do it that way. Also if I won't need columns for buttons, I could just have a simple QListWidget instead of a QTableView since I only have one data item cell, sounds good!

            • For the "selection" case. Instead of just typing into the data cell, the user needs something to click to take him to a dialog. I don't much care what that is. I was thinking of a ... button say to the right of each cell. But that will introduce a new column/widget, it won't be so easy to just do as QListWidget, and I don't know if QTableView allows columns just for widgets instead of the data. However, your new way I could just add one ... button, like one add and one delete, at table-level to use on whatever row is selected, which would solve.

            My one reservation is user having to understand that buttons for doing stuff on whatever is selected are at top/bottom. It saves on space, but it doesn't seem so immediately intuitive to me as having the buttons on each row. I don't use mobiles/Apples :) Is that a good way to do it? Anyone have a screenshot of what it looks like on some device? :)

            K Offline
            K Offline
            kshegunov
            Moderators
            wrote on 23 Nov 2018, 02:26 last edited by kshegunov
            #9

            @JonB said in Suitable "editable list" widget?:

            My one reservation is user having to understand that buttons for doing stuff on whatever is selected are at top/bottom. It saves on space, but it doesn't seem so immediately intuitive

            Well, quite often when working with tables you have context menus for that purpose. Take excel or open office spreadsheets as an example. There are 3 elements that are "duplicates" to make the UI as intuitive as possible for inserting rows above/below selection and deleting the selected row (just an example, but it applies to other operations as well):

            1. The menu - you get an entry that's enabled/disabled.
            2. The toolbar - same thing, but you have a button and and an icon (usually it's customizable as well).
            3. Context menu - right clicking gives you options pertaining to this particular UI element (like the main menu, but shorter).

            As a side kick, which I intentionally didn't include in the above list:

            • Keyboard shortcut(s) - yet another way to trigger one of the above

            So my best advice is to implement all of those (if possible).

            Read and abide by the Qt Code of Conduct

            J 1 Reply Last reply 23 Nov 2018, 08:06
            1
            • K kshegunov
              23 Nov 2018, 02:26

              @JonB said in Suitable "editable list" widget?:

              My one reservation is user having to understand that buttons for doing stuff on whatever is selected are at top/bottom. It saves on space, but it doesn't seem so immediately intuitive

              Well, quite often when working with tables you have context menus for that purpose. Take excel or open office spreadsheets as an example. There are 3 elements that are "duplicates" to make the UI as intuitive as possible for inserting rows above/below selection and deleting the selected row (just an example, but it applies to other operations as well):

              1. The menu - you get an entry that's enabled/disabled.
              2. The toolbar - same thing, but you have a button and and an icon (usually it's customizable as well).
              3. Context menu - right clicking gives you options pertaining to this particular UI element (like the main menu, but shorter).

              As a side kick, which I intentionally didn't include in the above list:

              • Keyboard shortcut(s) - yet another way to trigger one of the above

              So my best advice is to implement all of those (if possible).

              J Offline
              J Offline
              JonB
              wrote on 23 Nov 2018, 08:06 last edited by
              #10

              @kshegunov
              So: menu, toolbar, context menu & keyboard shortcut. That will all fit it into the 5 lines of code I expect to have to write to get this going, right?

              K 1 Reply Last reply 23 Nov 2018, 08:13
              0
              • J JonB
                23 Nov 2018, 08:06

                @kshegunov
                So: menu, toolbar, context menu & keyboard shortcut. That will all fit it into the 5 lines of code I expect to have to write to get this going, right?

                K Offline
                K Offline
                kshegunov
                Moderators
                wrote on 23 Nov 2018, 08:13 last edited by kshegunov
                #11

                @JonB said in Suitable "editable list" widget?:

                That will all fit it into the 5 lines of code I expect to have to write to get this going, right?

                Right. But when was the real solution as simple as we thought initially? Does such a unicorn exist?

                Seriously though, it boils down to creating one QAction and just adding it wherever it's supposed to go - menu, context menu, toolbar w/e.

                Read and abide by the Qt Code of Conduct

                J 1 Reply Last reply 23 Nov 2018, 09:08
                1
                • K kshegunov
                  23 Nov 2018, 08:13

                  @JonB said in Suitable "editable list" widget?:

                  That will all fit it into the 5 lines of code I expect to have to write to get this going, right?

                  Right. But when was the real solution as simple as we thought initially? Does such a unicorn exist?

                  Seriously though, it boils down to creating one QAction and just adding it wherever it's supposed to go - menu, context menu, toolbar w/e.

                  J Offline
                  J Offline
                  JonB
                  wrote on 23 Nov 2018, 09:08 last edited by JonB
                  #12

                  @kshegunov
                  I was about to plonk down one QListWidget/QTableWidget plus a couple of QPushButtons below it to do add/delete row in their clicked() signal's slot (right?). Why do I want/what benefit will I gain if I introduce a QAction? Sorry if this is dumb, I may have forgotten....

                  R 1 Reply Last reply 23 Nov 2018, 09:43
                  0
                  • J JonB
                    23 Nov 2018, 09:08

                    @kshegunov
                    I was about to plonk down one QListWidget/QTableWidget plus a couple of QPushButtons below it to do add/delete row in their clicked() signal's slot (right?). Why do I want/what benefit will I gain if I introduce a QAction? Sorry if this is dumb, I may have forgotten....

                    R Offline
                    R Offline
                    raven-worx
                    Moderators
                    wrote on 23 Nov 2018, 09:43 last edited by
                    #13

                    @JonB said in Suitable "editable list" widget?:

                    Why do I want/what benefit will I gain if I introduce a QAction?

                    to reuse the functionality in a menubar/toolbar/contextmenu for example

                    --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
                    If you have a question please use the forum so others can benefit from the solution in the future

                    J 1 Reply Last reply 23 Nov 2018, 09:49
                    2
                    • R raven-worx
                      23 Nov 2018, 09:43

                      @JonB said in Suitable "editable list" widget?:

                      Why do I want/what benefit will I gain if I introduce a QAction?

                      to reuse the functionality in a menubar/toolbar/contextmenu for example

                      J Offline
                      J Offline
                      JonB
                      wrote on 23 Nov 2018, 09:49 last edited by JonB
                      #14

                      @raven-worx
                      Yep, got it, thought so. So it's up to me: if I never want those (for right or for wrong) and only do clicked, I don't need a QAction.

                      1 Reply Last reply
                      0

                      14/14

                      23 Nov 2018, 09:49

                      • Login

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