为什么Qt应用程序标题后面是屏幕阅读器上的应用程序路径?

时间:2015-11-13 13:00:07

标签: qt accessibility screen-readers jaws-screen-reader nvda

我在Qt中有一个简单的应用程序,它有一个加载html页面的QMainWindow和一个QWebEngineView。我已设置QApplication名称和QMainWindow标题。

app.setApplicationName("FooApp");
window.setWindowTitle("FooApp Window");

当我使用屏幕阅读器时,它会将主窗口标题读为:

  

FooApp C:/Users/tulio/Desktop/TestApp//bin/debug/test.exe

我只是需要它来阅读应用程序名称,我该怎么做?

的main.cpp

#include "mainwindow.h"
#include <QApplication>

int main(int argc, char *argv[]) {
  QApplication a(argc, argv);

  a.setApplicationName("FooApp");

  MainWindow w;
  w.setWindowTitle("FooApp Window");
  w.show();

  return a.exec();
}

mainwindow.cpp

#include "mainwindow.h"
#include <QLayout>
#include <QApplication>

MainWindow::MainWindow(QWidget *parent)
  : QMainWindow(parent) {
  this->layout()->addWidget(&web_view_);
  this->layout()->setMargin(0);

  this->resize(QSize(1000, 700));

  QString path = QApplication::applicationDirPath() + "/index.html";
  qDebug() << QString("HTML Path %1").arg(path);

  web_view_.page()->setUrl(QUrl::fromLocalFile(path));
  web_view_.resize(this->size());

  channel_.registerObject("Test", &test_);
  web_view_.page()->setWebChannel(&channel_);
}

MainWindow::~MainWindow() {

}

void MainWindow::resizeEvent(QResizeEvent *event) {
  web_view_.resize(event->size());
}

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QWebEngineView>
#include <QResizeEvent>
#include <QWebChannel>
#include <QDebug>

class Test : public QObject
{
  Q_OBJECT
public:
  explicit Test(QObject *parent=0) : QObject(parent) {}
  virtual ~Test() {}
};

class MainWindow : public QMainWindow
{
  Q_OBJECT

public:
  MainWindow(QWidget *parent = 0);
  ~MainWindow();
private:
  QWebEngineView web_view_;
  QWebChannel channel_;
  Test test_;
protected:
  void resizeEvent(QResizeEvent *event);
};

#endif // MAINWINDOW_H

teste.pro

QT       += core gui webengine webenginewidgets webchannel

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = teste
TEMPLATE = app

SOURCES += main.cpp\
        mainwindow.cpp

HEADERS  += mainwindow.h

的index.html

<!DOCTYPE html>
<html>
    <body>
        <h1>Hello World!</h1>
    </body>
</html>

1 个答案:

答案 0 :(得分:0)

我认为您需要使用accessibleDescription : QString accessibleName : QString来保存辅助技术可以访问的解释。

相关问题