Hello,
I’m trying to embed a 3D model into a Qt window. For that, I’m using the QVTKOpenGLNativeWidget. However, I have to add also a QComboBox in a overlay. The problem is that the QComboBox popup list does not show if the window is fullscreen. The same also happens if I set tooltips.
For this project I’m using Qt 6.8.3, VTK 9.5.2, Windows 11 x64 and Visual Studio 2022.
Here I’m attaching a minimal reproducible code. Do you have any suggestion for solving the problem ?
Thanks a lot in advance ![]()
#include <QApplication>
#include <QMainWindow>
#include <QStackedLayout>
#include <QComboBox>
#include <QLabel>
#include <QVBoxLayout>
#include <QFrame>
#include <QVTKOpenGLNativeWidget.h>
#include <vtkGenericOpenGLRenderWindow.h>
#include <vtkRenderer.h>
int main(int argc, char* argv[]){
QApplication app(argc, argv);
QMainWindow window;
QWidget* central = new QWidget;
window.setCentralWidget(central);
QStackedLayout* stacked = new QStackedLayout(central);
stacked->setStackingMode(QStackedLayout::StackAll);
// QFrame container for VTK widget
QFrame* frame = new QFrame;
frame->setFrameShape(QFrame::Box);
frame->setLineWidth(2);
QVBoxLayout* frameLayout = new QVBoxLayout(frame);
frameLayout->setContentsMargins(0, 0, 0, 0);
frameLayout->setSpacing(0);
// VTK Widget
auto vtkRenderWidget = new QVTKOpenGLNativeWidget;
auto renderWindow = vtkSmartPointer<vtkGenericOpenGLRenderWindow>::New();
auto renderer = vtkSmartPointer<vtkRenderer>::New();
renderWindow->AddRenderer(renderer);
vtkRenderWidget->setRenderWindow(renderWindow);
renderer->SetBackground(0.1, 0.1, 0.2);
frameLayout->addWidget(vtkRenderWidget);
stacked->addWidget(frame);
// Overlay with QComboBox
QWidget* overlay = new QWidget;
overlay->setStyleSheet("background: rgba(255, 0, 0, 40);");
stacked->addWidget(overlay);
QVBoxLayout* vbox = new QVBoxLayout(overlay);
QLabel* label = new QLabel("Select value:");
QComboBox* combo = new QComboBox;
combo->addItems({ "Value 1", "Value 2", "Value 3" });
vbox->addWidget(label);
vbox->addWidget(combo);
vbox->addStretch();
stacked->setCurrentIndex(1);
window.showFullScreen();
//window.resize(800, 600);
//window.show();
return app.exec();
}