Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. [SOLVED] Awful flickering with QGridLayout on Mac OS X

[SOLVED] Awful flickering with QGridLayout on Mac OS X

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 2.1k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    agarny
    wrote on last edited by
    #1

    Hi,

    I am using a QGridLayout to show some widgets which I create on the fly, then delete, create others, etc. This all works fine, but on Mac OS X I get a really awful flickering (despite using setUpdatesEnabled()) while it's all fine on Windows and Linux.

    I have created a small Qt project which reproduces the problem (see below). I would really appreciate if someone could tell me whether I missed something obvious or whether it's a 'bug' on Mac OS X.

    Cheers, Alan.

    Test.pro:
    @QT += core gui

    TARGET = Test
    TEMPLATE = app

    SOURCES += main.cpp
    mainwindow.cpp

    HEADERS += mainwindow.h@

    main.cpp:
    @#include <QtGui/QApplication>
    #include "mainwindow.h"

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);
    MainWindow w;
    w.show();

    return a.exec&#40;&#41;;
    

    }@

    mainwindow.cpp:
    @#include "mainwindow.h"

    #include <QGridLayout>
    #include <QPushButton>

    MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent)
    {
    mWidget = new QWidget(this);

    mLayout = new QGridLayout(mWidget);
    
    mWidget->setLayout(mLayout);
    
    populate();
    
    setCentralWidget(mWidget);
    
    this->resize(600, 300);
    

    }

    void MainWindow::populate()
    {
    setUpdatesEnabled(false);

    for (int i = 0, iMax = mLayout->count(); i < iMax; ++i) {
        QLayoutItem *item = mLayout->takeAt(0);
    
        delete item->widget();
        delete item;
    }
    
    for (int i = 0; i < 3; ++i)
        for (int j = 0; j < 3; ++j) {
            QPushButton *button = new QPushButton("Click me!", mWidget);
    
            connect(button, SIGNAL(clicked()), this, SLOT(populate()));
    
            mLayout->addWidget(button, i, j);
        }
    
    setUpdatesEnabled(true);
    

    }@

    mainwindow.h:
    @#ifndef MAINWINDOW_H
    #define MAINWINDOW_H

    #include <QMainWindow>

    class QGridLayout;

    class MainWindow : public QMainWindow
    {
    Q_OBJECT

    public:
    explicit MainWindow(QWidget *parent = 0);

    private:
    QWidget *mWidget;
    QGridLayout *mLayout;

    private Q_SLOTS:
    void populate();
    };

    #endif@

    1 Reply Last reply
    0
    • A Offline
      A Offline
      agarny
      wrote on last edited by
      #2

      See http://www.qtcentre.org/threads/49840-Awful-flickering-with-QGridLayout-on-Mac-OS-X?p=223935#post223935 for the 'solution'...

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved