I have encountered some issues regarding the QT window DLL.
-
I am using Ruby C extensions in Sketchup to call QT windows.
I compiled using the vc142 environment instead of qmake.
1.How should I handle QApplication? I have already initialized an app every time a window is displayed.
2.After app. exec(), Sketchup no longer receives any key events.#include "quickseachdialog.h" #include <QtWidgets/QWidget> #include <QtWidgets/QApplication> #include "RubyUtils.h" static bool init_app = false; class QuickSeachDialog : public QWidget { public: QuickSeachDialog(QWidget* parent = nullptr); ~QuickSeachDialog(); }; QuickSeachDialog::QuickSeachDialog(QWidget *parent) : QWidget(parent) { // 设置窗口标题和尺寸 setWindowTitle("Search Command"); resize(800, 600); } QuickSeachDialog::~QuickSeachDialog() { } VALUE rbf_show_quick_seach(VALUE self) { int argc = 0; char* argv[] = { nullptr }; QApplication app(argc, argv); QuickSeachDialog dialog; dialog.show(); app.exec(); return Qnil; } void InitQtDialog() { VALUE DFC = rb_define_module("DFC"); VALUE qt_dialog = rb_define_class_under(DFC, "QtDialog", rb_cObject); rb_define_module_function(qt_dialog, "show_quick_seach", VALUEFUNC(rbf_show_quick_seach), 0); } -
Hi and welcome to devnet,
Your return statement will only execute when you end the Qt application part such as when closing the dialog.
Are you sure that the architecture of Sketchup allows for a secondary event loop to be running or that it could be controlled by the Sketchup event loop ? -
Hi and welcome to devnet,
Your return statement will only execute when you end the Qt application part such as when closing the dialog.
Are you sure that the architecture of Sketchup allows for a secondary event loop to be running or that it could be controlled by the Sketchup event loop ?@SGaist said in I have encountered some issues regarding the QT window DLL.:
Are you sure that the architecture of Sketchup allows for a secondary event loop to be running or that it could be controlled by the Sketchup event loop ?
I'm not sure.
Sketchup 2022 is developed based on MFC, while Sketchup 2023 is developed based on QT5.
Should I send the event from QApplication to the Sketchup main window. -
If there's already a Qt event loop running, you should not need to create a new one.
That said, did you check with the Sketchup folks to see if there's a documented way to use Qt in the plugins ?
-
If there's already a Qt event loop running, you should not need to create a new one.
That said, did you check with the Sketchup folks to see if there's a documented way to use Qt in the plugins ?
@SGaist Thank you. Let me ask.