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. Add an accessible role to an existing class
Forum Updated to NodeBB v4.3 + New Features

Add an accessible role to an existing class

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 4 Posters 1.1k Views 2 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.
  • O Offline
    O Offline
    Oreonan
    wrote on last edited by
    #1

    Hi,
    I'm trying to add an accessible role to an existing class.
    For example, a role tree in a class of type QTreeWidget
    There is a way to do this without rewrite all code to create an accessible class?
    I readed all examples of qtbase/src/widget/accessible but I sucess nothing when I trying to use it on my existing app :(

    raven-worxR 1 Reply Last reply
    0
    • O Oreonan

      Hi,
      I'm trying to add an accessible role to an existing class.
      For example, a role tree in a class of type QTreeWidget
      There is a way to do this without rewrite all code to create an accessible class?
      I readed all examples of qtbase/src/widget/accessible but I sucess nothing when I trying to use it on my existing app :(

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      @Oreonan
      for items widgets (which QTreeWidget is) the accesible data is coming from the model data

      --- 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

      1 Reply Last reply
      0
      • O Offline
        O Offline
        Oreonan
        wrote on last edited by
        #3

        Yes :), however I tried to set Qt::AccessibleRole, but it gives an compilation error

        raven-worxR 1 Reply Last reply
        0
        • O Oreonan

          Yes :), however I tried to set Qt::AccessibleRole, but it gives an compilation error

          raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by raven-worx
          #4

          @Oreonan
          a little bit more information would be helpful in order to help you
          https://doc.qt.io/qt-5/qt.html#ItemDataRole-enum
          There is no Qt::AccessibleRole value for example, but a Qt::AccessibleTextRole

          --- 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

          SGaistS 1 Reply Last reply
          2
          • O Offline
            O Offline
            Oreonan
            wrote on last edited by
            #5

            So I can't associate a QTreeWidgetItem to checkbox accessible role for example?

            raven-worxR 1 Reply Last reply
            0
            • O Oreonan

              So I can't associate a QTreeWidgetItem to checkbox accessible role for example?

              raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              @Oreonan
              what do you mean with that?

              --- 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

              1 Reply Last reply
              0
              • O Offline
                O Offline
                Oreonan
                wrote on last edited by
                #7

                I have a model representing a tree with 2 columns, one for item name, one for state (enabled/disabled). I want to set an accessible role to checkbox because I think like this a screen reader can be able to say if an item is enabled or disabled. Currently I use the accessible text role to do that but it's not a good solution for me.

                VRoninV raven-worxR 2 Replies Last reply
                0
                • O Oreonan

                  I have a model representing a tree with 2 columns, one for item name, one for state (enabled/disabled). I want to set an accessible role to checkbox because I think like this a screen reader can be able to say if an item is enabled or disabled. Currently I use the accessible text role to do that but it's not a good solution for me.

                  VRoninV Offline
                  VRoninV Offline
                  VRonin
                  wrote on last edited by
                  #8

                  @Oreonan said in Add an accessible role to an existing class:

                  one for state (enabled/disabled)

                  How is this represented? QTreeWidget can represent "chackboxes" natively

                  "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

                  1 Reply Last reply
                  0
                  • O Offline
                    O Offline
                    Oreonan
                    wrote on last edited by VRonin
                    #9

                    It's representing by a QModel with 2 columns and using Qt::DisplayRole, here is a part of code:

                        case Qt::DisplayRole :
                            if(orientation == Qt::Horizontal)
                            {
                                switch(section)
                                {
                                case COLUMN_NAME: return tr("Event");
                                case COLUMN_CHECK: return tr("Enabled");
                                }
                            }
                            break;
                    
                        case Qt::DisplayRole :
                            if (index.column() == COLUMN_CHECK)
                                return (m_ttsselected & m_ttsevents[index.row()])? tr("Enabled") : tr("Disabled");
                            Q_ASSERT(index.column() == COLUMN_NAME);
                            switch(m_ttsevents[index.row()])
                            {
                            case TTS_USER_LOGGEDIN :
                                return tr("User logged in");
                            case TTS_USER_LOGGEDOUT :
                                return tr("User logged out");
                    //...
                    
                    1 Reply Last reply
                    0
                    • raven-worxR raven-worx

                      @Oreonan
                      a little bit more information would be helpful in order to help you
                      https://doc.qt.io/qt-5/qt.html#ItemDataRole-enum
                      There is no Qt::AccessibleRole value for example, but a Qt::AccessibleTextRole

                      SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      Hi,
                      As suggested by @raven-worx
                      @raven-worx said in Add an accessible role to an existing class:

                      Qt::AccessibleTextRole

                      Why not return the values you want for that role ?

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • O Oreonan

                        I have a model representing a tree with 2 columns, one for item name, one for state (enabled/disabled). I want to set an accessible role to checkbox because I think like this a screen reader can be able to say if an item is enabled or disabled. Currently I use the accessible text role to do that but it's not a good solution for me.

                        raven-worxR Offline
                        raven-worxR Offline
                        raven-worx
                        Moderators
                        wrote on last edited by
                        #11

                        @Oreonan said in Add an accessible role to an existing class:

                        I have a model representing a tree with 2 columns, one for item name, one for state (enabled/disabled). I want to set an accessible role to checkbox because I think like this a screen reader can be able to say if an item is enabled or disabled. Currently I use the accessible text role to do that but it's not a good solution for me.

                        i haven't used the accessible framework for a while, but i think you will have to create a custom accessible interface (plugin or in source) for your tree widget to represent the checkbox in the interface

                        --- 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

                        1 Reply Last reply
                        0
                        • O Offline
                          O Offline
                          Oreonan
                          wrote on last edited by
                          #12

                          Oh, hmmmm, I readed this doc but it's really difficult to do this I think :)

                          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