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. Multiple Widgets in QDialog -> Multiple "active" selections

Multiple Widgets in QDialog -> Multiple "active" selections

Scheduled Pinned Locked Moved General and Desktop
9 Posts 3 Posters 4.5k 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.
  • S Offline
    S Offline
    strangelookingnerd
    wrote on last edited by
    #1

    Hey!

    I got a config dialog as a QDialog with multiple widgets to configure my main application. So i got QComboBoxes, QListView, QTableView and so on.
    I got some kind of "feature" to select an item in a QListView (QStandardItemModel) and add a selection (the text of the QStandardItem) at a selected position in a QTableView (QStandardItemModel). The adding works perfect but i lack of some visual feedback to the user.
    Since if i select an item in the QListView, it turns blue as an "active" selection. Now I select an item in the QTableView to alter it.
    Result: the QTableViews selection becomes "active" and therefore blue. The previous selection in the QListView turns greyish, like a nonactive selection. I'd like to keep this selection also active and blue.

    I guess its because you can only have one active selection in a QDialog/QWidget. Is there any way to change this behavior?

    so long...

    1 Reply Last reply
    0
    • F Offline
      F Offline
      fluca1978
      wrote on last edited by
      #2

      This is a behaviour that depends on the component that has the focus. All the selections are still enabled, but the colour changes due to the component that looses the focus to give it to another one. I believe that having all the selection "active" will confuse the user that no more understands on which component he is working.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        strangelookingnerd
        wrote on last edited by
        #3

        So there is no possibility of having a visible focus on more than one widget?

        1 Reply Last reply
        0
        • F Offline
          F Offline
          fluca1978
          wrote on last edited by
          #4

          As far as I know, no. And it will not depend on Qt either, it is the underlying windowing system that establishes that. The best you can do, but I would definitively avoid it, is to force a window theme so that inactive items will not become grayed, but this would confuse your users.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            andre
            wrote on last edited by
            #5

            Actually, you can achieve this.
            There are a few ways to achieve what you want. You could fiddle with the style, by subclassing QProxyStyle and overriding how your listview gets rendered. Another approach to do the same, is to create a custom delegate for your list view. That way, you can also fully control the rendering of each item, and you can make items look the same irrespective if the widget has focus or not.

            1 Reply Last reply
            0
            • S Offline
              S Offline
              strangelookingnerd
              wrote on last edited by
              #6

              The current approach I'm working on includes the QItemSelectionModel::selectionChanged() signal, connected to a method as slot which paints the selected item as desired and resetting the rest. I doubt the efficiency of this approach on larger tables, but since there are only like 20-30 items I think it could do the job :)

              I'll let you know if it worked out!

              1 Reply Last reply
              0
              • A Offline
                A Offline
                andre
                wrote on last edited by
                #7

                No, that is not the right approach. Painting is done from the paintevent, and I have already laid out the options you have to manipulate that. Your way is not going to work.

                1 Reply Last reply
                0
                • F Offline
                  F Offline
                  fluca1978
                  wrote on last edited by
                  #8

                  [quote author="Andre" date="1322641156"]Actually, you can achieve this.
                  There are a few ways to achieve what you want. You could fiddle with the style, by subclassing QProxyStyle and overriding how your listview gets rendered. Another approach to do the same, is to create a custom delegate for your list view. That way, you can also fully control the rendering of each item, and you can make items look the same irrespective if the widget has focus or not. [/quote]

                  Right! Never thought about that for this scenario.

                  1 Reply Last reply
                  0
                  • S Offline
                    S Offline
                    strangelookingnerd
                    wrote on last edited by
                    #9

                    [quote author="Andre" date="1322646685"]No, that is not the right approach. Painting is done from the paintevent, and I have already laid out the options you have to manipulate that. Your way is not going to work. [/quote]

                    Actually it worked with some tweaks here and there. But there were some side-effects I didn't think of. I tried creating custom delegates, which works as expected!

                    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