QGraphicsRecItem::setRect causing a SIGSEGV error
-
I’m having a hard time with a function in the QGraphicsRecItem class with either variation of the setRect function.
setRect(qreal x, qreal y, qreal width, qreal height)
or...
setRect(const QRectF &rectangle)I keep receiving a SISSEGV Error when I attempt to use the setRect function. It’s probably something simple that I’m looking right at, but I’ve been pounding my head against this all week and I have yet to see it. I'm hoping another set of eyes might spot the problem. Thank you in advance for any assistance you can provide.
In the code below, lines commented out are simply things I tried.
void GridWindow::setupWindow(bool bkgrnd) { qreal wFactor; qreal hFactor; QBrush bkgrndBrush; // Paintbrush for the background QString sceneDescriptor; // Indicates the background used QPixmap gridPic; // Holds background grid image QRectF sceneRect; sceneRect.setX(50); sceneRect.setY(50); if(bkgrnd){ // If 1000 x 1000 grid is requested if(!gridPic.load(fileNm1000)) qDebug() << "Could not load " << fileNm1000; dotSize = 5; sceneDescriptor.append("1000x1000 Grid"); sceneRect.setWidth(1000); sceneRect.setHeight(1000); }else{ // If 600 x 600 grid is requested if(!gridPic.load(fileNm600)) qDebug() << "Could not load " << fileNm600; dotSize = 5; sceneDescriptor.append("600x600 Grid"); sceneRect.setWidth(600); sceneRect.setHeight(600); } wFactor = gridPic.width(); hFactor = gridPic.height(); bkgrndBrush.setTexture(gridPic); // Set brush with pixmap pGridScene = new QGraphicsScene(0, 0, wFactor, hFactor, this); pGridScene->installEventFilter(this); pGridScene->setBackgroundBrush(bkgrndBrush); ui->gridView->setScene(pGridScene); //QRectF testRect(sceneRect); // Variable in size commented out // to allow hardcoding as below //pGridRect->setRect(sceneRect); // *** SISEGV Error Here!!! //pGridRect->setRect(testRect); // *** SISEGV Error Here!!! //pGridRect->setRect(sceneRect); // *** SISEGV Error Here!!! pGridRect->setRect(50.0, 50.0, 600.0, 600.0); // *** SISEGV Error Here!!!
-
I’m having a hard time with a function in the QGraphicsRecItem class with either variation of the setRect function.
setRect(qreal x, qreal y, qreal width, qreal height)
or...
setRect(const QRectF &rectangle)I keep receiving a SISSEGV Error when I attempt to use the setRect function. It’s probably something simple that I’m looking right at, but I’ve been pounding my head against this all week and I have yet to see it. I'm hoping another set of eyes might spot the problem. Thank you in advance for any assistance you can provide.
In the code below, lines commented out are simply things I tried.
void GridWindow::setupWindow(bool bkgrnd) { qreal wFactor; qreal hFactor; QBrush bkgrndBrush; // Paintbrush for the background QString sceneDescriptor; // Indicates the background used QPixmap gridPic; // Holds background grid image QRectF sceneRect; sceneRect.setX(50); sceneRect.setY(50); if(bkgrnd){ // If 1000 x 1000 grid is requested if(!gridPic.load(fileNm1000)) qDebug() << "Could not load " << fileNm1000; dotSize = 5; sceneDescriptor.append("1000x1000 Grid"); sceneRect.setWidth(1000); sceneRect.setHeight(1000); }else{ // If 600 x 600 grid is requested if(!gridPic.load(fileNm600)) qDebug() << "Could not load " << fileNm600; dotSize = 5; sceneDescriptor.append("600x600 Grid"); sceneRect.setWidth(600); sceneRect.setHeight(600); } wFactor = gridPic.width(); hFactor = gridPic.height(); bkgrndBrush.setTexture(gridPic); // Set brush with pixmap pGridScene = new QGraphicsScene(0, 0, wFactor, hFactor, this); pGridScene->installEventFilter(this); pGridScene->setBackgroundBrush(bkgrndBrush); ui->gridView->setScene(pGridScene); //QRectF testRect(sceneRect); // Variable in size commented out // to allow hardcoding as below //pGridRect->setRect(sceneRect); // *** SISEGV Error Here!!! //pGridRect->setRect(testRect); // *** SISEGV Error Here!!! //pGridRect->setRect(sceneRect); // *** SISEGV Error Here!!! pGridRect->setRect(50.0, 50.0, 600.0, 600.0); // *** SISEGV Error Here!!!