From 7fa1337cd82ec94ae0ea54102c8e6718ee0e35f1 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 10 Apr 2024 22:40:56 +0200 Subject: [PATCH 1/2] Moving from QFormBuilder to QUiLoader as QFormBuilding is deprecated in Qt6 binding --- src/doc/doc/programming/qt_binding.xml | 9 ++++----- src/lay/lay/macro_templates/qt_designer.lym | 2 +- src/lay/lay/macro_templates/qt_designer_python.lym | 2 +- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/doc/doc/programming/qt_binding.xml b/src/doc/doc/programming/qt_binding.xml index 4d298d922..8ee752745 100644 --- a/src/doc/doc/programming/qt_binding.xml +++ b/src/doc/doc/programming/qt_binding.xml @@ -29,7 +29,6 @@
  • QtXmlPatterns (Qt5): XML schema and queries
  • QtSql: database support
  • QtNetwork: various network protocols and supporting classes
  • -
  • QtDesigner: dynamically load designer files (.ui)
  • QtUiTools: dynamically load designer files (.ui)
  • QtMultimedia (Qt5): multimedia support
  • QtPrintSupport (Qt5): print support
  • @@ -244,7 +243,7 @@ end ui_file = QFile::new(QFileInfo::new($0).dir.filePath("MyDialog.ui")) ui_file.open(QIODevice::ReadOnly) - dialog = QFormBuilder::new.load(ui_file, Application::instance.main_window) + dialog = QUiLoader::new.load(ui_file, Application::instance.main_window) ui_file.close def dialog.setup @@ -260,11 +259,11 @@ end

    This sample tries to locate a designer file called "MyDialog.ui" relative to the - macro's path (in $0). It uses the class to load and + macro's path (in $0). It uses the class to load and create the dialog. In that sample, "MyDialog" defines a dialog with two widgets: a QPushButton ("button") and a QSlider ("slider"). Because of the dynamic binding in Ruby, "dialog" will already have the correct class and - we don't have to cast the pointer delivered by QFormBuilder::load before we can call "exec". + we don't have to cast the pointer delivered by QUiLoader::load before we can call "exec".

    @@ -312,7 +311,7 @@ end

    b = dialog.button
    -# this will not render true, if the button was created by QFormBuilder for example
    +# this will not render true, if the button was created by QUiLoader for example
     b.is_a?(QPushButton)
     # this is correct:
     b.is_a?(QPushButton_Native)
    diff --git a/src/lay/lay/macro_templates/qt_designer.lym b/src/lay/lay/macro_templates/qt_designer.lym index d26b3a01b..4e1933695 100644 --- a/src/lay/lay/macro_templates/qt_designer.lym +++ b/src/lay/lay/macro_templates/qt_designer.lym @@ -20,7 +20,7 @@ # Initially we use the sample file provided as resource ui_file = QFile::new(":/macro-templates/qt_designer.ui") ui_file.open(QIODevice::ReadOnly) - dialog = QFormBuilder::new.load(ui_file, Application::instance.main_window) + dialog = QUiLoader::new.load(ui_file, Application::instance.main_window) ui_file.close def dialog.setup diff --git a/src/lay/lay/macro_templates/qt_designer_python.lym b/src/lay/lay/macro_templates/qt_designer_python.lym index 2d9f46eb5..dffd41731 100644 --- a/src/lay/lay/macro_templates/qt_designer_python.lym +++ b/src/lay/lay/macro_templates/qt_designer_python.lym @@ -17,7 +17,7 @@ import types ui_file = pya.QFile(":/macro-templates/qt_designer.ui") ui_file.open(pya.QIODevice.ReadOnly) -form = pya.QFormBuilder().load(ui_file, pya.Application.instance().main_window()) +form = pya.QUiLoader().load(ui_file, pya.Application.instance().main_window()) ui_file.close() # Install an event handler for the button clicked event From ae2d6fb42f63a66361d2dfc3fd02fef50ec22182 Mon Sep 17 00:00:00 2001 From: Matthias Koefferlein Date: Wed, 10 Apr 2024 23:18:51 +0200 Subject: [PATCH 2/2] Updating sample macros for Qt6 compatibility --- src/lay/lay/macro_templates/qt_dialog.lym | 2 +- src/lay/lay/macro_templates/qt_dialog_python.lym | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lay/lay/macro_templates/qt_dialog.lym b/src/lay/lay/macro_templates/qt_dialog.lym index a97c7f8e1..681ce4701 100644 --- a/src/lay/lay/macro_templates/qt_dialog.lym +++ b/src/lay/lay/macro_templates/qt_dialog.lym @@ -32,7 +32,7 @@ layout.addWidget(@image) button = QPushButton.new('Screenshot', self) - button.setFont(QFont.new('Times', 18, QFont::Bold)) + button.setFont(QFont.new('Times', 18, QFont::Bold.to_i)) layout.addWidget(button) button.clicked do diff --git a/src/lay/lay/macro_templates/qt_dialog_python.lym b/src/lay/lay/macro_templates/qt_dialog_python.lym index 2291e0787..3e4cee917 100644 --- a/src/lay/lay/macro_templates/qt_dialog_python.lym +++ b/src/lay/lay/macro_templates/qt_dialog_python.lym @@ -49,7 +49,7 @@ class ScreenshotDialog(pya.QDialog): layout.addWidget(self.image) button = pya.QPushButton('Screenshot', self) - button.setFont(pya.QFont('Times', 18, pya.QFont.Bold)) + button.setFont(pya.QFont('Times', 18, int(pya.QFont.Bold))) layout.addWidget(button) # attach the event handler