[Qt-interest] Screen Getting White

Alexandre Beraud aberaud at infflux.com
Tue Apr 21 14:40:49 CEST 2009


Hi,

Sorry, I don't have the courage to examine your code in depth, but I can 
see some issues.
*for(i=1; i<=numberOfPoints; i++)
*You should not count up to numberOfPoints. Use < instead of <=. I would 
advise tu use QList whenever you can, instead of new QObject[]. 
Moreover, there is no point in calling processEvents() outside of a loop 
in your case. If you have a long running loop somewhere, call 
processEvents() every, say, 100ms (via a QTimer for example) so that the 
paintEvents() can be processed. These are only advices, I don't think 
they will fix up your issue.

Regards,

Alex


Sujan Dasmahapatra a écrit :
>
> Dear Friends
>
> I am into the development of an engineering software where I am 
> loading multiple geometries from the QFileDialog and displaying them 
> on the main window and at the same time the file names are being 
> uploaded onto the QTableWdiget one by one. I am using a QGraphicsScene 
> and QGraphicsView which is used for display, the default Scene color 
> is black..Everything is going fine but sometimes when I load a 
> geometry the screen is getting white and no geometries are found.But 
> actually the geometries are there and filename is nicely uploaded in 
> my QTableWidget. If I continue the operation and if I load another 
> geometry next then all the geometries are coming back on the screen 
> and all are visible.I am facing this problem severely.
>
> I thought that I am not refreshing the screen during and after loading 
> the geometry so I am calling “qApp->processEvents()” before and after 
> loading the geometry as one of our friends suggested but it’s still 
> happening and I am fade up with this bug.Please help me somebody.
>
> Some codes I am writing here for understanding.
>
> ////////////////////////////////////////////Scene and View 
> Management///////////////////////
>
> * scene = new GraphicsScene;*
>
> * view = new QGraphicsView(scene);*
>
> * view->setWindowTitle(QT_TRANSLATE_NOOP(QGraphicsView,"Geometry View"));*
>
> * view->setGeometry(250,70,1020,646);*
>
> * view->setParent(this,Qt::SubWindow);*
>
> * scene->setParent(view);*
>
> */////////////////////////loading 
> geometry/////////////////////////////////////////////////////////*
>
> *void MainWindow::open()*
>
> *{*
>
> * qApp->processEvents();*
>
> * int i;*
>
> * xmax=0.0,xmin=0.0,ymax=0.0,ymin=0.0;*
>
> * fileopendialog.setAcceptMode(QFileDialog::AcceptOpen);*
>
> * if(fileopendialog.exec())*
>
> * {*
>
> * Filenames = fileopendialog.selectedFiles();*
>
> * }*
>
> * if(Filenames[0].isEmpty())*
>
> * return;*
>
> * *
>
> * if(fileopendialog.result()==QDialog::Rejected)*
>
> * return;*
>
> * *
>
> * if(!firstTime)*
>
> * {*
>
> * if(tableWidget->countTableWidget == 0)*
>
> * {*
>
> * countMainWindow = 0;*
>
> * fileGeometry.clear();*
>
> * geometry.clear();*
>
> * }*
>
> * }*
>
> * if(fileopendialog.selectedNameFilter()=="*.dat")*
>
> * {*
>
> * fileGeometry.append(Filenames[0]);*
>
> * QFile file(fileGeometry[countMainWindow]);*
>
> * file.open(QIODevice::ReadOnly);*
>
> * QTextStream stream(&file);*
>
> * QString ch;*
>
> * ch = stream.read(2);*
>
> * stream >> numberOfPoints;*
>
> * x =new double[numberOfPoints];*
>
> * y = new double[numberOfPoints];*
>
> * QPointF *dataPoints = new QPointF[numberOfPoints];*
>
> * for(i = 0; i< numberOfPoints; i++)*
>
> * {*
>
> * stream >> x[i] >> y[i];*
>
> * dataPoints[i].setX(x[i]);*
>
> * dataPoints[i].setY(y[i]);*
>
> * *
>
> * }*
>
> * xmax = dataPoints[0].x();*
>
> * *
>
> * for(i=1; i<=numberOfPoints; i++)*
>
> * {*
>
> * if(dataPoints[i].x() > xmax)*
>
> * xmax = dataPoints[i].x();*
>
> * }*
>
> * *
>
> * xmin = dataPoints[0].x();*
>
> * *
>
> * for(i=1; i<=numberOfPoints; i++)*
>
> * {*
>
> * if(dataPoints[i].x() < xmin )*
>
> * xmin = dataPoints[i].x();*
>
> * }*
>
> * *
>
> * width = xmax-xmin;*
>
> * if(width <0.0)*
>
> * width = width * (-1.0);*
>
> * *
>
> * ymax = dataPoints[0].y();*
>
> * *
>
> * for(i=1; i<=numberOfPoints; i++)*
>
> * {*
>
> * if(dataPoints[i].y() > ymax)*
>
> * ymax = dataPoints[i].y();*
>
> * }*
>
> * *
>
> * ymin = dataPoints[0].y();*
>
> * *
>
> * for(i=1; i<=numberOfPoints; i++)*
>
> * {*
>
> * if(dataPoints[i].y() < ymin)*
>
> * ymin = dataPoints[i].y();*
>
> * }*
>
> * *
>
> * height = ymax-ymin;*
>
> * if(height < 0.0)*
>
> * height = height * (-1.0);*
>
> * geometry.append(new Geometry(numberOfPoints,dataPoints));*
>
> * file.close();*
>
> * delete x;*
>
> * delete y;*
>
> * }*
>
> * else if(fileopendialog.selectedNameFilter()=="*.tyk")*
>
> * {*
>
> * fileGeometry.append(Filenames[0]);*
>
> * QFile filetykread(fileGeometry[countMainWindow]);*
>
> * filetykread.open(QIODevice::ReadOnly);*
>
> * QTextStream stream(&filetykread);*
>
> * stream >> numberOfPoints;*
>
> * numberOfPoints = numberOfPoints;*
>
> * double *xval = new double[numberOfPoints];*
>
> * double *ytop = new double[numberOfPoints];*
>
> * double *ybot = new double[numberOfPoints];*
>
> * for(i=0; i<numberOfPoints; i++)*
>
> * {*
>
> * stream >> xval[i] >> ytop[i] >> ybot[i];*
>
> * }*
>
> * *
>
> * numberOfPoints = (2*numberOfPoints);*
>
> * x = new double[numberOfPoints-1];*
>
> * y = new double[numberOfPoints-1];*
>
> * QPointF *dataPoints = new QPointF[numberOfPoints-1];*
>
> * *
>
> * for(i=0; i<(numberOfPoints-1); i++)*
>
> * {*
>
> * if(i<=(numberOfPoints/2)-1)*
>
> * {*
>
> * x[i] = xval[(numberOfPoints/2)-1-i];*
>
> * y[i] = ybot[(numberOfPoints/2)-1-i];*
>
> * }*
>
> * if(i>=numberOfPoints/2)*
>
> * {*
>
> * x[i] = xval[i-(numberOfPoints/2)+1];*
>
> * y[i] = ytop[i-(numberOfPoints/2)+1];*
>
> * }*
>
> * }*
>
> * for(i=0; i<(numberOfPoints-1);i++)*
>
> * {*
>
> * dataPoints[i].setX(x[i]);*
>
> * dataPoints[i].setY(y[i]);*
>
> * }*
>
> * xmax = dataPoints[0].x();*
>
> * *
>
> * for(i=1; i<=numberOfPoints; i++)*
>
> * {*
>
> * if(dataPoints[i].x() > xmax)*
>
> * xmax = dataPoints[i].x();*
>
> * }*
>
> * *
>
> *xmin = dataPoints[0].x();*
>
> * *
>
> * for(i=1; i<=numberOfPoints; i++)*
>
> * {*
>
> * if(dataPoints[i].x() < xmin )*
>
> * xmin = dataPoints[i].x();*
>
> * }*
>
> * *
>
> * width = xmax-xmin;*
>
> * if(width <0.0)*
>
> * width = width * (-1.0);*
>
> * *
>
> * ymax = dataPoints[0].y();*
>
> * *
>
> * for(i=1; i<=numberOfPoints; i++)*
>
> * {*
>
> * if(dataPoints[i].y() > ymax)*
>
> * ymax = dataPoints[i].y();*
>
> * }*
>
> * *
>
> * ymin = dataPoints[0].y();*
>
> * *
>
> * for(i=1; i<=numberOfPoints; i++)*
>
> * {*
>
> * if(dataPoints[i].y() < ymin)*
>
> * ymin = dataPoints[i].y();*
>
> * }*
>
> * *
>
> * height = ymax-ymin;*
>
> * if(height < 0.0)*
>
> * height = height * (-1.0);*
>
> * geometry.append(new Geometry(numberOfPoints-1,dataPoints));*
>
> * filetykread.close();*
>
> * delete xval;*
>
> * delete ytop;*
>
> * delete ybot;*
>
> * delete x;*
>
> * delete y;*
>
> * }*
>
> * else*
>
> * {*
>
> * statusBar()->showMessage(tr("Unknown format"),2000);*
>
> * }*
>
> * qApp->processEvents();*
>
> * scene->addItem(geometry[countMainWindow]);*
>
> * tableWidget->fileNameUpdate(fileGeometry[countMainWindow], 
> geometry[countMainWindow]);*
>
> * view->fitInView(geometry[countMainWindow],Qt::KeepAspectRatio); 
> //This two functions are fitting the geometry on the view*
>
> * view->setSceneRect(xmin,-ymax,width,height);*
>
> * view->show();*
>
> * statusBar()->showMessage(tr("Part loaded"),2000);*
>
> * consoleView->append(fileGeometry[countMainWindow] + " is loaded");*
>
> * countMainWindow++;*
>
> * firstTime = false;*
>
> * qApp->processEvents();*
>
> * *
>
> *}*
>
> * *
>
> *///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*
>
> Kind regards,
> LM Glasfiber R&D (India) Pvt. Ltd.
>
> Sujan Dasmahapatra
> Project Engineer - CFD
>
> Telephone: +91 80 66470248
> Mobile:
> E-mail: sdh at lmglasfiber.com <mailto:sdh at lmglasfiber.com>
>
> --------------------------------------------------------------
>
> This e-mail and any attachments are confidential. If you are not the 
> named or intended recipient, please notify the sender immediately and 
> do not disclose the contents to any other person, use it for any 
> purpose or store or copy the information in any medium. Any 
> unauthorized disclosure, use or storage is prohibited and might be 
> unlawful.
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest
>   


-- 
BERAUD Alexandre
Ingénieur Développement

Infflux - Informatique & Flux
Tel: 01 49 57 92 00 - Fax : 01 49 57 92 01
Mail: aberaud at infflux.com
Visitez notre site :  www.infflux.com





More information about the Qt-interest-old mailing list