Custom UI with QT for LibreOffice 7. Where to start?

Hello all!

I am trying to implement some customisation for UI based on Qt for LibrOffice 7. I found QtInstance.cxx class and this class methods somehow calling when window created. Could someone help me with understanding of how to implement my own UI component based on QWidget?

The questions that I have right now:
– How the Qt instance with QApplication connected to LibreOffice engine?
– How libroffice events transmitting to QApplication?
– How window and frame connected to QApplication and how it creating at time of application start?
– How to add my own QWidget to Libr UI?

I’ve tried to find it by my own, but got failed. Any help with it?

1 Like

Simple answer: you can’t. LO just uses QWidget as a drawing area. In the end, everything is painted via QtWidget::paintEvent. All the other events (mouse, keyboard, focus, etc.) are just forwarded to the LO internal toolset, VCL. The low level part lives in /vcl/source/.

There is a different theming interface used by gtk3, include/vcl/weld.hxx, which actually uses native gtk widgets. So you would somehow be able to influence the gtk widget hierarchy, but that is not possible with Qt, unless someone implements the weld interface for Qt. And it would probably break the whole VCL <> native toolkit interaction.

That’s basically the same answer I gave above.

That’s what a VCL plugin, like qt5 (vcl/qt5/) or gtk3 (vcl/unx/gtk3) is. A way for the LO application to communicate with different OS.

A LO window is a QWidget for the VCL qt plugin, LO’s abstraction calls a window a frame, so all the window handling for Qt is handled in the QtFrame class.

You can’t. It’s also like my first answer.

What you can do is using libreofficekit. This is some major part of the LO “engine”, which can be embedded into other applications. There is libreofficekit/Executable_gtktiledviewer.mk, which is a gtk example to embed LO to render documents in a gtk application. It’s the same way LO Online renders and edits the documents. But this way you must implement the whole UI yourself.

Read up on Development - The Document Foundation Wiki. Then just ask on IRC.

1 Like

Thanks for reply. It’s extremely useful.

Can I be implementing libreofficekit into Qt Application based on QWidget or QQuickItem? Is there any examples of this approach?

Am I right? - if I am implementing weld interface for Qt there will be option to develop different them for LO UI? If yes, how difficult to develop weld interface?

What is the best approach to develop custom UI for LO?
What is the fastest approach to develop custom UI for LO?

I assume you mean embed instead of implementing. I don’t see why not. The kf5 plugin, which is derivated from the qt5 plugin, uses cairo and blits the painted result to a QImage per defaukt (it’s implemented in qt5 too and can be switched with SAL_VCL_QT5_USE_CAIRO). There is no existing Qt approach I’m aware of, but you must basically follow the gtk approach implemented in libreofficekit/source/gtk/.

I’m not really understanding this question. But maybe some info about the difference between the old theming interface and the new / weld theming helps you. The difference is the level of abstraction. In the old way LO just asks the OS API to paint a dialogs widgets. But the behavior of the dialog is completely LO controlled and also the layout. With weld the native dialog, like QMessageBox is used. This can be seen for native GTK3 message dialogs. If a native widget doesn’t support some behavior a LO widget needs, you can still fall back to a drawing area widget and let LO do the whole painting and widget interaction.

The main problem is not difficult but laborious. The old API is split into various widgets, which can be implemented individually. So LO asks the VCL plugin, if it supports native buttons and then either calls the plugins function to paint a button or paints it itself (see vcl/inc/WidgetDrawInterface.hxx). AFAIK this kind of separation doesn’t exists with weld; at least it wasn’t obvious when I looked into this years ago. Implementing weld for Qt will take quite some time until anything works. As a data point: when I wrote the initial qt5 plugin, it took me a weekend to see some broken LO UI. But I suggest to just ask Caolan on IRC, since weld is his baby.

IMHO there is just the LOKit way, if you want to use some platform specifics, like native Qt. Or implement your UI using LO + VCL itself. The first one limits you to everything Qt can do (there is still the branch feature/qt5-win+mac, where I did build LO with Qt on Mac and Windows), the 2nd one will result in something that will run on all LO supported platforms. The first approach is like a different project just using LO technology, like LO online. You might get help from the LOOL devs, as they are the primary user and developer of LOKit; the 2nd one may get you more help from the LO development team, but you might need to do more work to get controversial patches in.

See the answer above.


FWIW: you didn’t even mention, what you’re planning to do. Answers might change in a more specific light of your UI ideas, but I guess not much would change, as they are rather generic. HTH you coming to some conclusion.

My primary target is maintainable by small team Custom UI for LO. For now it’s difficult to develop and maintain custom UI by small team, especially you don’t know LO code and project architecture. This project is HUGE!

When I’ve found info about Qt I’ve started researching into “how Qt is working inside”. Qt for me is more comfort technology than GTK. I am from Qt World, especially for mobile devices, here my channel about developing on Qt for Mobile https://www.youtube.com/channel/UCwl-_Z0IYL0KYPKu8QgGpKQ Therefore the best solution for me is to use QML UI with LO, where key LO functionality wrapped out into QtQuickItem. For example word processing widget wrapped out into QQuickItem and can be implemented into QML.

What I found right now that is made me a little confused:

– QApplication is running in “faked main function”, I understand why so. But it’s making complications in slot-signals in some cases and might be slowing down Qt module performance. But all of it my experience.
– Ability to use QWidget directly (you already answered on this question and few experiments made it more clear for me now
– few less critical things

One of the possible approach for me is developing Qml Application where word processing, calc processing and etc is wrapped out into QQuickItem that make it be much better in maintenance by small team.