QWebEngine crash with exception code 0x80000003

QWebEngine is a new web browser engine introduced in Qt 5.4, it’s used to replace the old QWebView. QWebView is based on WebKit, while QWebEngine is based on Chromium browser, so it’s faster and supports more features.

I wrote a very simple program to test QWebEngine, following is the code:

Compiling and running is smooth. But when I tried to run this demo on another machine, it crashed, and an error dialog is shown with the message “An unknown software exception (0x80000003) has occurred at 0x023c5b7e. Click OK to terminate the program.

By chekcing the log file (debug.log) I found some helpful information:

[ERROR:icu_util.cc(154)] Couldn’t mmap D:\Qt\Qt5.4.0\5.4\msvc2013_64\icudtl.dat
[FATAL:content_main_runner.cc(719)] Check failed: base::i18n::InitializeICU()

We can see the icudtl.dat path is not correct, because it doesn’t exist at all.

To fix it we need to create a new file named “qt.conf” under the application directory, and fill it with following content:

 

(This bug is posted at https://bugreports.qt.io/browse/QTBUG-42083)

Qt QWidget add menu bar

I want to add menu bar to my window (which is a QWidget instance), I searched on the Google and found that most articles are recommending to use QMainWindow instead of QWidget. Using QMainWindow is a good choice, but in my program the main window is based on QWidget and the code base is huge, so adding menu bar to QWidget is a better choice here.

First we need create a window (QWidget) and set its layout (we use QVBoxLayout here)

Then create a menu bar and add it to the VBox layout.

Now you will see a blank menu bar in your window

Next we need add some menus to our menu bar

addMenu function will take the parameter as menu name and return the menu as return value. We need keep the menu instances because we need add actions (menu items) to them.

In above code we create a QAction (menu item) with title “Exit”, and connect its “triggered” signal to exit function (sys.exit), it means when this menu item is clicked, the exit function will be called. Finally add this menu item to the “File” menu.

 

We can also connect QAction’s triggered signal to custom defined function

Here we add a “Redo” menu item under “Edit” menu. When user clicks “Redo”, a message box will be popped up saying “Redo will be performed”

 

Following is the complete code:

 

remove horizontal header of QTableView

QTableView will show the horizontal header and vertical header by default.

Now I want to use QTableView as a file list to show the files changed recently (I want to list more than one column, so QTableView is a better choice than QListView). we can use following code to remove the horizontal header:

PySide

c++

horizontalHeader() method will return the horizontal header which is an instance of QHeaderView class. Then call the hide method of QHeaderView class to hide the header.

QHeaderView class is inheriting QWidget class, so we can use hide method to make it invisible and use show method to make it visible. You can view the QWidget documentation here