QGraphicsView - slow scale performance under Linux

I'm making a program that will display a few images from a directory beside each other.

When I scale the images to fit within the height of the window (ie - QGraphicsPixmapItem->scale(...)), it runs fairly well in windows, but runs unbearably slow in linux (Ubuntu 11.04).

If the images are not scaled, performance is similar on both systems.

I'm not sure if it has to do with the way each OS caches memory, since when I run the program under Linux, the memory used is always constant and around 5mb, when it's closer to 15-30mb under Windows depending on the images loaded.

Here is the related code:

MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent)
    scene = new QGraphicsScene(this);
    view = new QGraphicsView(scene);
    bestFit = true;

    view->setHorizontalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
    view->setVerticalScrollBarPolicy ( Qt::ScrollBarAlwaysOff );
    view->setStyleSheet( "QGraphicsView { border-style: none; padding: 5px; background-color: #000; }" );   // set up custom style sheet

    // Get image files from folder
    QDir dir("test_img_folder");
    QStringList fileList = dir.entryList();
    fileList = fileList.filter(QRegExp(".*(\.jpg|\.jpeg|\.png)$"));

    // Create graphics item for each image
    int count = 0;
    foreach(QString file, fileList)
    if (count >= 0)
        QPixmap g(dir.absolutePath() + QString("/") + file);
    if (count >= 5) break;

void MainWindow::resizeEvent(QResizeEvent *event)
    int pos = 0;
    foreach(QGraphicsItem *item, scene->items(Qt::AscendingOrder))
        double ratio = 1.0;
        QGraphicsPixmapItem *pixmapItem = (QGraphicsPixmapItem*) item;

        // Resize to fit to window
        if (bestFit) {
            double h = (double) (view->height()-10)/pixmapItem->pixmap().height();
            ratio = min(h, 1.0);

        // Position 5 pixels to the right of the previous image
        pos += pixmapItem->pixmap().width()*ratio + 5;

    // Resize scene to fit items


You could try different graphicssystems e.g. with the command line switch -graphicssystem raster|native|opengl or by setting the environment variable QT_GRAPHICSSYSTEM to "raster" etc.

In my experience, I agree with trying the QT_GRAPHICSSYSTEM environment variable hack. It took me some time in development of a new real-time QT4 application, with high bandwidth callbacks, to discover that setting QT_GRAPHICSSYSTEM = 'raster', prevented my RedHat Linux X11 system from gobbling up CPU time. So I suspect there is a resource issue when QT_GRAPHICSSYSTEM is not set or set to 'native'.

Need Your Help

how to determine at runtime which function to call in vbscript

vbscript qtp

The range of input values possible is quite huge in my case. So a select-case methodology will not work.

Close all modal dialogs in Dojo

dojo dialog modal-dialog

Does anybody know how I can close all modal dialogs created by Dojo ? Apparently there used to be a dojo.popup.closeAll function, but this is no longer available in the latest version of the Dojo API