Dialog
Appearance
TDF LibreOffice Document Liberation Project Community Blogs Weblate Nextcloud Redmine Ask LibreOffice Donate
Dialog |
Introduction
Dialog is used to show a dialog box, which is a window that interacts with the user. It can contain other widgets.
Screenshots
Dialog is displayed differently in different UI plugins.


Code
#include <sal/config.h>
#include <framework/desktop.hxx>
#include <cppuhelper/bootstrap.hxx>
#include <comphelper/processfactory.hxx>
#include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <i18nlangtag/languagetag.hxx>
#include <i18nlangtag/mslangid.hxx>
#include <vcl/svapp.hxx>
#include <vcl/weld/DialogController.hxx>
#include <vcl/weld/weld/Window.hxx>
#include <sal/main.h>
#include <iostream>
namespace
{
class TheDialog : public weld::GenericDialogController
{
public:
TheDialog(weld::Window* pParent = nullptr);
};
TheDialog::TheDialog(weld::Window* pParent)
: weld::GenericDialogController(pParent, u"cui/ui/Dialog.ui"_ustr,
u"Dialog"_ustr)
{
}
class TheApplication : public Application
{
public:
virtual int Main();
};
int TheApplication::Main()
{
TheDialog dialog;
dialog.run();
return 0;
}
}
SAL_IMPLEMENT_MAIN()
{
try
{
TheApplication aApp;
auto xContext = cppu::defaultBootstrap_InitialComponentContext();
css::uno::Reference<css::lang::XMultiServiceFactory> xServiceManager(
xContext->getServiceManager(), css::uno::UNO_QUERY);
comphelper::setProcessServiceFactory(xServiceManager);
LanguageTag::setConfiguredSystemLanguage(MsLangId::getSystemLanguage());
InitVCL();
aApp.Main();
framework::getDesktop(::comphelper::getProcessComponentContext())->terminate();
DeInitVCL();
comphelper::setProcessServiceFactory(nullptr);
}
catch (...)
{
std::cerr << "An exception has occurred\n";
return 1;
}
return 0;
}
<?xml version="1.0" encoding="UTF-8"?>
<interface domain="cui">
<requires lib="gtk+" version="3.24"/>
<object class="GtkDialog" id="Dialog">
<property name="can-focus">False</property>
<child>
<placeholder/>
</child>
</object>
</interface>
Native Implementations
- GTK3: GtkDialog
- GTK4: GtkDialog
- Qt5: QDialog
- Qt6: QDialog
- Windows: Window handle (HWND) to Win32 Window
- macOS: NSWindow
Links
- weld::Dialog Class Reference
- weld::Dialog in LibreOffice core source code