2

I have a simple application in Qt that has a QMainWindow and a QWebEngineView that loads an html page. I've set the QApplication name and the QMainWindow title.

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

When I use a screen reader, it will read the main window title as:

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

I just need it to read the application name, how can I do this?

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>
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Tolio
  • 1,023
  • 13
  • 30

1 Answers1

0

I think you need to use accessibleDescription : QString accessibleName : QString which holds the desciption that gets accessed by assistive technologies.

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358
Mailerdaimon
  • 6,003
  • 3
  • 35
  • 46