PDA

View Full Version : A problem with multiple QGraphicsView-s with OpenGL rendering



MadBear
15th September 2010, 18:31
Greetings,
I have run into a strange problem with multiple QGraphicsView-s and OpenGL rendering.
I need to implement an application with multiple QGraphicsView-s (each has it's own scene). I have implemented OpenGL rendering just like in documentation (view.setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));) for each view, but now if I use OpenGL rendering in more than one QGraphicsView every one of them shows only black screen (no items are drawn). Is this some kind of a bug, or am I missing something? Please help. Thank you in advance.

Regards,
MadBear

e8johan
16th September 2010, 14:08
Sounds like a driver issue to me. What platform, Qt version and driver version do you use? Can you reproduce it with a very basic scene? If so, file a bug report with Nokia.

MadBear
27th September 2010, 06:59
Greetings,
First I want to thank you for your reply.
I have updated drivers, but the problem persists (I'm developing the application in OpenSUSE linux). I have also created small application to test this situation:


MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
QPixmap slika;
slika.load("bug.jpg");
int w=slika.width();
ui->graphicsView->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
ui->graphicsView_2->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
QGraphicsPixmapItem *pix=new QGraphicsPixmapItem;
pix->setPixmap(slika);
QGraphicsScene *scena=new QGraphicsScene;
ui->graphicsView->setScene(scena);
scena->addItem(pix);
ui->graphicsView->resetTransform();
ui->graphicsView->scale(1,1);
ui->graphicsView_2->setScene(scena);
ui->graphicsView_2->resetTransform();
ui->graphicsView_2->scale(1,1);
}


Now if I use OpenGL in only one of the views application works without problem. But if I use OpenGL in both views it shows only 2 black squares where an image is supposed to be. The error it shows is:

X Error: BadValue (integer parameter out of range for operation) 2
Extension: 135 (Uknown extension)
Minor opcode: 16 (Unknown request)
Resource id: 0x20de

Am I doing something wrong. I have used 2 GLWidgets in application and it worked without a problem. So what is wrong here? It is driving me insane. :confused:
Thank you.

Regards,
MadBear

JohannesMunk
27th September 2010, 14:12
Mmh.. this works fine here. Maybe you can try it.


#include <QtCore>
#include <QtGui>
#include <QtOpenGL>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);

QHBoxLayout* hl = new QHBoxLayout();

QGraphicsScene* scene = new QGraphicsScene();
QWidget* wdg = new QWidget();
wdg->setGeometry(0,0,150,150);
wdg->setWindowTitle("Title1");

QGraphicsProxyWidget* proxy = scene->addWidget(wdg);
proxy->setWindowFlags(Qt::Dialog | Qt::CustomizeWindowHint | Qt::WindowTitleHint);
proxy->setPos(-150,0);

QGraphicsPixmapItem* pix = scene->addPixmap(QPixmap("e:/test.jpg"));
pix->setScale(0.1);
pix->setPos(50,0);

{
QGraphicsView* view = new QGraphicsView();
view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
view->setScene(scene);
hl->addWidget(view);
}

{
QGraphicsView* view = new QGraphicsView();
view->setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
view->setScene(scene);
QTransform t;
t.scale(0.5,0.5);
view->setTransform(t);
hl->addWidget(view);
}

QWidget* w = new QWidget();
w->setLayout(hl);
w->setGeometry(QRect(50, 50, 600, 400));
w->show();
return a.exec();
}

Joh

Wim
20th October 2010, 08:13
I have the same problem as the OP, and the sample code from Johannes shows the proxy widget OK, but the images are two black rectangles.
If I modify the code to show just one QGraphicsView the image shows correctly.
If I modify the code so the second view is not scaled, the images are black and I get exactly the same error as the one reported by the OP:
X Error: BadValue (integer parameter out of range for operation) 2
Extension: 128 (Uknown extension)
Minor opcode: 16 (Unknown request)
Resource id: 0x20de

This is with Qt 4.6.2 on a 64-bit Kubuntu 10.4 with all the updates installed.
Grahpics card is a nVidia Quadro NVS 285 using the proprietary nVidia driver version 195

A windows build of the same code using VC 2008 Express with Qt 4.6.3 works correctly. There were some OpenGL related changes sin 4.6.3, but I am not sure if they are related to this issue. If I have time I will try to update my Qt version on Linux to see if that helps.