Jump to content

How to design some gui like in Unigine Editor by Qt


photo

Recommended Posts

Posted

Hello! I'm working with UNIGINE 2 Sim Per-Channel (2.19.1.2) in Ubuntu 24.04.03 LTS. I want to design an application with Qt GUI and viewport in the same window like Unigine Editor (I see the editor also uses Qt). I took a look to generated code by SDK when I created C++(Cmake + Qt) application template. I saw that viewport is rendered to an internal SystemProxyQtWindow. So I think I should edit this window to obtain my purpose. I tried to add a button in SystemProxyQtWindow contructor:

QPushButton *button = new QPushButton("Click Me", this);

But the button isn't displayed. I also tried to add a child widget, made getWinHandle() return to window handle of this child (also in SystemProxyQtWindow contructor), hoping viewport will be rendered in this child and will not break the button:

m_viewportWidget = new QWidget{this};
m_viewportWidget->setFixedSize(1080, 1080);
QPushButton *button = new QPushButton("Click Me", this);
const WId win_id = m_viewportWidget->winId();
memcpy(&win_handle_, &win_id, sizeof(win_handle_));

But I see transparent areas instead of added widgets (in following picture). I think I should re-implement these methods that window-related functions of SystemProxyQt calls but I don't really understand how they works. If any suggestions, I'll be very thankful. Sorry for my bad Еnglish.

Screenshot from 2025-12-19 13-08-01.png

Posted (edited)

I realized that I can insert a Qt widget into an external window after checking the 3rd Party ViewportQt sample. I tried to forward Qt events to Unigine by using CustomSystemProxy::invokeInputEvent(InputEventPtr e) in overrided QWidget::event(QEvent *event) method. The problem is: In the external window, Unigine events are correctly invoked but there is no response from my PlayerSpectator object. In intenal window SystemProxyQtWindow, everything works fine. So I'm wondering the PlayerSpectator responds when Unigine::InputEvent is invoked or with some additional conditions? Thanks!

 

Edited by donaltrung
×
×
  • Create New...