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. QAccessible and QPushButton
Forum Updated to NodeBB v4.3 + New Features

QAccessible and QPushButton

Scheduled Pinned Locked Moved General and Desktop
13 Posts 2 Posters 4.9k 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.
  • K Offline
    K Offline
    Kudaiv
    wrote on last edited by
    #1

    At first, sorry for my English)) Please, can somebody help me to understand how to enable Accessibility in Qt. Particulary i'm interested in VoiceOver (mac). Here i tried to make some example with simple programm - just one button and VoiceOver support.
    @
    //WidgetInterface.h
    #ifndef ACCESSIBLE_H
    #define ACCESSIBLE_H

    #include <QAccessibleWidget>
    #include <QRect>
    #include <QWidget>

    class AccessiblePushButton : public QAccessibleWidget
    {
    public:
    AccessiblePushButton(QWidget *widget, Role role = Client,
    const QString & name = QString()) : QAccessibleWidget(widget, role, name){}
    int childCount() const{ return 0; }
    QRect rect(int child) const
    {
    return widget()->rect();
    }
    QString text(Text text, int child) const
    {
    switch (text)
    {
    case Value:
    return "Hello";
    case Name:
    return "QPushButton";
    case Description:
    return "This is pushbutton";
    case Help:
    return "Help for pushbutton";
    default:
    break;
    }
    return QAccessibleWidget::text(text, child);
    }
    Role role(int child) const{ return QAccessible::PushButton; }

    };

    #endif@

    @#include <QtGui/QApplication>
    #include <QPushButton>
    #include <QAccessibleInterface>
    #include "WidgetInterface.h"

    QAccessibleInterface *buttonFactory(const QString &classname, QObject *object)
    {
    QAccessibleInterface *interface = 0;

    if (classname == "QPushButton")
        interface = new AccessiblePushButton(static_cast<QWidget *>(object));
    return interface;
    

    }

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    QAccessible::installFactory(buttonFactory);
    QPushButton pb("Hello");
    pb.show();
    return a.exec();
    }@

    pro file
    @
    QT += core gui

    TARGET = test_voice_over
    TEMPLATE = app

    SOURCES += main.cpp
    HEADERS += WidgetInterface.h
    QTPLUGIN += qtaccessiblewidgets
    @

    Or if someone has completelly, working example - please help))
    I will be very grateful! ))

    thanks in advance!

    1 Reply Last reply
    0
    • raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by
      #2

      actually Qt already provides accessibility implementations for the base widgets (e.g. QPushButton, ...)
      Just copy the accessiblewidgets Qt plugin so your application loads it.
      The plugin can be found in the standard Qt plugin path.

      If you built Qt yourself make sure you have built it with accessible support.

      --- 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
      • K Offline
        K Offline
        Kudaiv
        wrote on last edited by
        #3

        [quote author="raven-worx" date="1390217125"]actually Qt already provides accessibility implementations for the base widgets (e.g. QPushButton, ...)
        Just copy the accessiblewidgets Qt plugin so your application loads it.
        The plugin can be found in the standard Qt plugin path.

        If you built Qt yourself make sure you have built it with accessible support.[/quote]
        GreatThanks! I found that the Internet is not much documentation and examples on this subject...
        I guess i need to set Accessiblename and AccessibleDescription - that's right? And VoiceOver will read accessibleName when focus on my widget?

        1 Reply Last reply
        0
        • raven-worxR Offline
          raven-worxR Offline
          raven-worx
          Moderators
          wrote on last edited by
          #4

          Maybe they will already be set implicitly also by Qt at appropriate places, but make sure and set them manually.

          [quote author="Kudaiv" date="1390217637"]
          I guess i need to set Accessiblename and AccessibleDescription - that's right? And VoiceOver will read accessibleName when focus on my widget?
          [/quote]
          Can't answer that, sry. Never used accessibility on a Mac.

          --- 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
          • K Offline
            K Offline
            Kudaiv
            wrote on last edited by
            #5

            Ok, i found this post http://stackoverflow.com/questions/3893560/qt-accessible-widgets and it seems easy, so tried like this
            @
            #include <QLabel>
            #include <QtPlugin>

            Q_IMPORT_PLUGIN(qtaccessiblewidgets)

            int main(int argc, char *argv[])
            {
            QApplication a(argc, argv);
            QLabel pb("Hello");
            pb.setAccessibleName("Helloo");
            pb.setAccessibleDescription("Button");
            pb.show();
            return a.exec();
            }
            @

            @QT += core gui

            TARGET = test_voice_over
            TEMPLATE = app

            SOURCES += main.cpp

            HEADERS += WidgetInterface.h

            QTPLUGIN += qtaccessiblewidgets

            @

            every time i've got this error
            "qt_plugin_instance_qtaccessiblewidgets()", referenced from:
            global constructors keyed to mainin main.o
            ld: symbol(s) not found for architecture x86_64

            what's wrong?

            1 Reply Last reply
            0
            • raven-worxR Offline
              raven-worxR Offline
              raven-worx
              Moderators
              wrote on last edited by
              #6

              you do not need this line in your pro-File:
              QTPLUGIN += qtaccessiblewidgets

              the qtaccessiblewidgets plugin is loaded automatically at runtime ifQt is able to find it.

              You only need this line when you build your app statically. Which doesn't look so seeing the rest of the pro-File.

              --- 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
              • K Offline
                K Offline
                Kudaiv
                wrote on last edited by
                #7

                Thank you! And now i think that my Qt were build with no-accessibility...
                and

                @qt_plugin_instance_qtaccessiblewidgets()”, referenced from: global constructors keyed to mainin main.o
                ld: symbol(s) not found for architecture x86_64
                @
                testifies about it. But i can find qtaccessiblewidgets plugin in standart plugin path...

                1 Reply Last reply
                0
                • K Offline
                  K Offline
                  Kudaiv
                  wrote on last edited by
                  #8

                  [quote author="raven-worx" date="1390375476"]you do not need this line in your pro-File:
                  QTPLUGIN += qtaccessiblewidgets

                  the qtaccessiblewidgets plugin is loaded automatically at runtime ifQt is able to find it.

                  You only need this line when you build your app statically. Which doesn't look so seeing the rest of the pro-File.
                  [/quote]

                  Q_IMPORT_PLUGIN(qtaccessiblewidgets)
                  this need for static plugins too?

                  1 Reply Last reply
                  0
                  • raven-worxR Offline
                    raven-worxR Offline
                    raven-worx
                    Moderators
                    wrote on last edited by
                    #9

                    yes, see "this":http://qt-project.org/doc/qt-4.8/plugins-howto.html#static-plugins.
                    If you link your application dynamically to Qt you don't have to worry about anything in your code. Just that the plugins are located in the correct path.

                    --- 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
                    • K Offline
                      K Offline
                      Kudaiv
                      wrote on last edited by
                      #10

                      it's funny but qt can't load libqtaccessiblewidgets.dylib in runtime
                      (i'm using DYLD_PRINT_LIBRARIES=1 QT_DEBUG_PLUGINS=1 myapp)
                      so i'm doing something like this
                      @ QPluginLoader loader(a.applicationDirPath() + "/../PlugIns/accessible/libqtaccessiblewidgets.dylib");
                      qDebug() << a.applicationDirPath();
                      bool isLoad = loader.load();
                      qDebug() << isLoad << " " << loader.errorString() ; @
                      and qt.conf on it's place! And nothing...
                      but when i'm using DYLD_PRINT_LIBRARIES=1 QT_DEBUG_PLUGINS=1 myapp i see this
                      QFactoryLoader::QFactoryLoader() looking at "/Users/sergey/test_voice_over/test_voice_over.app/Contents/PlugIns/accessible/libqtaccessiblewidgets.dylib"
                      keys ("QLineEdit", "QComboBox", "QAbstractSpinBox", "QSpinBox", "QDoubleSpinBox", "QScrollBar", "QSlider", "QAbstractSlider", "QToolButton", "QCheckBox", "QRadioButton", "QPushButton", "QAbstractButton", "QDialog", "QMessageBox", "QMainWindow", "QLabel", "QLCDNumber", "QGroupBox", "QStatusBar", "QProgressBar", "QMenuBar", "Q3PopupMenu", "QMenu", "QHeaderView", "QTabBar", "QToolBar", "QWorkspaceChild", "QSizeGrip", "QAbstractItemView", "QWidget", "QSplitter", "QSplitterHandle", "QTextEdit", "QPlainTextEdit", "QTipLabel", "QFrame", "QStackedWidget", "QToolBox", "QMdiArea", "QMdiSubWindow", "QWorkspace", "QDialogButtonBox", "QDial", "QRubberBand", "QTextBrowser", "QAbstractScrollArea", "QScrollArea", "QCalendarWidget", "QDockWidget")

                      and trying to create simpliest app with one button with VoiceOver support
                      @int main(int argc, char *argv[])
                      {
                      QApplication a(argc, argv);

                      QPluginLoader loader(a.applicationDirPath() + "/../PlugIns/accessible/libqtaccessiblewidgets.dylib");
                      qDebug() << a.applicationDirPath();
                      bool isLoad = loader.load();
                      qDebug() << isLoad << " " << loader.errorString() ;
                      
                      QPushButton pb("Hello button");
                      pb.show();
                      
                      return a.exec&#40;&#41;;
                      

                      }
                      @
                      WSAA works fine with this code... what's wrong with voice over?

                      1 Reply Last reply
                      0
                      • K Offline
                        K Offline
                        Kudaiv
                        wrote on last edited by
                        #11

                        maybe i should to install some factory of accessible interfaces from qtaccessibleplugin using QAccessible::installFactory ?

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          Kudaiv
                          wrote on last edited by
                          #12

                          and QAccessibility::isActive everytime returns false ((

                          1 Reply Last reply
                          0
                          • raven-worxR Offline
                            raven-worxR Offline
                            raven-worx
                            Moderators
                            wrote on last edited by
                            #13

                            which version of Qt are you using? Qt 4 or Qt 5?
                            With Qt (5.1?) the accessible support has been "improved ":http://blog.qt.digia.com/blog/2012/06/18/qt-5-accessibility-apis/on Mac OS X.

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

                            • Login

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