Add a QGLView object to Qt GUI application
-
This question has been asked before and I want to expand on it. How to render in Qt3D in standard GUI application? but I cannot find an answer.
Now that we have the QT 5.3 and above versions available, is it possible to have a subwindow of QGLView window into an existion mainwindow application?
The MdiArea is fine and I am able to see the subwindow1 as a part of my central widget.
I am also able to view the QGL object window when I write view. show.
Problem:When I wrap the QGLView window object into a widget wrapper using QWidget::createWindowContainer(view); and then use this widget inside subwindow 2, i get multiple windows popping up and error: Invalid parameter passed to C runtime function.
How do i view this QGLView window inside a subwindow.
@MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
view=0;mainlayout= new QVBoxLayout; displaywidget= new QHBoxLayout; QLabel *label = new QLabel("<h1><font color = RED> Tangible textures </font> </h1>");// create the application title //create the icons for all the UI push button and resize the buttons ui->pushButton->setIcon(QIcon(":/pattern4.jpg")); ui->pushButton->resize(buttonsize); mainDisplay= new QMdiArea;//mainDisplay is the Mdi Area subwindow1= new QMdiSubWindow; subwindow1->setWidget(ui->pushButoon); mainDisplay->addSubWindow(subwindow1); subwindow2= new QMdiSubWindow; setCentralWidget(mainDisplay);
}
void MainWindow::on_pushButton_clicked()
{
//if this is the first button to be clicked on the UI
if(view==NULL)
{
view=new CubeView();
view->begin(4);
view->resize(800, 600);
container = QWidget::createWindowContainer(view);
subwindow2->setWidget(container);
mainDisplay->addSubWindow(subwindow2);
}}
MainWindow::~MainWindow()
{
delete ui;
if(view!=NULL){
std::cout<<"view object deleted"<<std::endl;
delete view;}
delete mainlayout;
delete catalogue;
delete subwindow;
delete scrollregion;
}@