Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-10318

QFrame Background drawn outside frame rect when embedded in QGraphicsView

    XMLWordPrintable

Details

    Description

      I embedded a QFrame into a QGraphicsScene. When I zoom in really close to the QFrame, the frame's background is drawn outside of the frame's drawn shape. The attached image shows the bottom of the frame and you can see the grey background outside the frame by a couple of pixels. I am actually using qt from the qt 4.7 branch.

      #include <QApplication>
      #include <QFrame>
      #include <QLabel>
      #include <QVBoxLayout>
      #include <QGraphicsView>
      #include <QGraphicsScene>
      #include <QKeyEvent>
      
      class MyGraphicsView : public QGraphicsView
      {
      public:
      	MyGraphicsView(QGraphicsScene *scene) : QGraphicsView(scene) { }
      protected:
      	void keyReleaseEvent(QKeyEvent *event);
      };
      
      void MyGraphicsView::keyReleaseEvent(QKeyEvent *event)
      {
      	if(event->key() == Qt::Key_S)
      	{
      		scale(1.10,1.10); 
      	}
      	else if(event->key() == Qt::Key_A)
      	{
      		scale(1/1.10,1/1.10); 
      	}
      }
      
      int main(int argc, char ** argv)
      {
      	QApplication app(argc,argv);
      	QFrame * mainWindow = new QFrame();
      	QGraphicsScene *scene = new QGraphicsScene();
      	MyGraphicsView *view = new MyGraphicsView(scene);
      	QFrame *subWindow = new QFrame();
      	subWindow->setGeometry(0,0,256,64);
      	subWindow->setFrameShape(QFrame::Box);
      	QLabel *label1 = new QLabel("Label number 1");
      	QVBoxLayout *subWindowLayout = new QVBoxLayout();
      	subWindowLayout->addWidget(label1);
      	subWindow->setLayout(subWindowLayout);
      	scene->addWidget(subWindow);
      	QVBoxLayout *layout = new QVBoxLayout();
      	layout->addWidget(view);
      	mainWindow->setLayout(layout);
      	mainWindow->setGeometry(50,50,512,256);
      	mainWindow->show();
      	int returnValue = app.exec();
      	delete mainWindow;
                           return returnValue;
      }
      
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            ylopes Yoann Lopes
            steno Jon Mullen
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes