How should i do to make a qwidget cover qvulkanwindow
-
I want to use a qvulkanwindow to show someting rendered by vulkan.And create a qwidget which cover that vulkanwindow,to deal some Qt event like mousemove or keyboard.And add some sub window into that widget such as Game inventory like minecraft.
but is does not work.i make sure that when i add single widget or single qwidget pointer create by QWdiget::createWindowContainer,they will pretty good.but when i try to combine them,the pointer always occur all area on the top surface of application,and the widget doesn‘t show.
how can i do to deal it?
that is the basic code for test:
main.cpp:#include <QApplication> #include <QMainWindow> #include <QPushButton> #include <iostream> #include "code.h" #include "PGW.h" using namespace std; int main(int argc, char* argv[]) { QApplication a(argc, argv); code c = code(); c.show(); return a.exec(); // RenderPass(); }
code.cpp:
#include "code.h" #include <QPushButton> #include <iostream> #include <QDebug> #include <QVulkanWindow> #include <QVulkanInstance> #include "PGW.h" //#include "render.h" using namespace std; code::code() { this->setGeometry(0,0,1000,1000); QWindow* a = new QWindow(); QWidget* b = QWidget::createWindowContainer(a, this); b->setGeometry(0,0,1000,1000); QWidget* w = new QWidget(this); w->setGeometry(0, 0, 100, 100); w->setStyleSheet("background-color: red;"); w->raise(); w->show(); } code::~code() { }
this is the header file(code.h):
#pragma once #include <QMainWindow> class code : public QWidget { Q_OBJECT public: code(); ~code(); };
the red widget object doesn`t show,whever what i try to codeing.
-
I want to use a qvulkanwindow to show someting rendered by vulkan.And create a qwidget which cover that vulkanwindow,to deal some Qt event like mousemove or keyboard.And add some sub window into that widget such as Game inventory like minecraft.
but is does not work.i make sure that when i add single widget or single qwidget pointer create by QWdiget::createWindowContainer,they will pretty good.but when i try to combine them,the pointer always occur all area on the top surface of application,and the widget doesn‘t show.
how can i do to deal it?
that is the basic code for test:
main.cpp:#include <QApplication> #include <QMainWindow> #include <QPushButton> #include <iostream> #include "code.h" #include "PGW.h" using namespace std; int main(int argc, char* argv[]) { QApplication a(argc, argv); code c = code(); c.show(); return a.exec(); // RenderPass(); }
code.cpp:
#include "code.h" #include <QPushButton> #include <iostream> #include <QDebug> #include <QVulkanWindow> #include <QVulkanInstance> #include "PGW.h" //#include "render.h" using namespace std; code::code() { this->setGeometry(0,0,1000,1000); QWindow* a = new QWindow(); QWidget* b = QWidget::createWindowContainer(a, this); b->setGeometry(0,0,1000,1000); QWidget* w = new QWidget(this); w->setGeometry(0, 0, 100, 100); w->setStyleSheet("background-color: red;"); w->raise(); w->show(); } code::~code() { }
this is the header file(code.h):
#pragma once #include <QMainWindow> class code : public QWidget { Q_OBJECT public: code(); ~code(); };
the red widget object doesn`t show,whever what i try to codeing.