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

border of rect is not disabled after selection

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P4: Low
    • None
    • 4.6.3
    • Widgets: GraphicsView
    • None

    Description

      I created a little subclass of QGraphicsRectItem.
      There I changed the enumeration Type but then I saw if I select the item the right border and border below are not disabled. After reset of Type everything works fine.

      I don't know why this happens but I think it is not correct. I excpected that it the the same view like the parent class QGraphicsRectItem after selection.

      I also attached a image where these two different things are shown.

      mainwindow.h:

      #include <QMainWindow>
      #include <QGraphicsScene>
      #include <QGraphicsTextItem>
      #include <QGraphicsRectItem>
      
      namespace Ui {
          class MainWindow;
      }
      
      class MainWindow : public QMainWindow {
          Q_OBJECT
      public:
          MainWindow(QWidget *parent = 0);
          ~MainWindow();
      
      protected:
          void changeEvent(QEvent *e);
      		QGraphicsScene *scene;
      		QGraphicsTextItem *text;
      		QGraphicsRectItem *rect;
      
      private:
          Ui::MainWindow *ui;
      
      	private slots:
      		void click123();
      };
      

      mainwindow.cpp:

      #include "mainwindow.h"
      #include "ui_mainwindow.h"
      
      #include <QGraphicsSvgItem>
      #include <QGraphicsRectItem>
      
      #include "myrect.h"
      
      MainWindow::MainWindow(QWidget *parent) :
          QMainWindow(parent),
          ui(new Ui::MainWindow)
      {
          ui->setupUi(this);
      
      		scene = new QGraphicsScene();
      
      		ui->graphicsView->setScene(scene);
      
      		connect(ui->pushButton, SIGNAL(clicked()), this, SLOT(click123()));
      
      		rect = new MyRect();
      		rect->setFlag(QGraphicsItem::ItemIsSelectable);
      		rect->setRect(50, 50, 200, 200);
      
      		scene->addItem(rect);
      
      }
      
      MainWindow::~MainWindow()
      {
          delete ui;
      }
      
      void MainWindow::changeEvent(QEvent *e)
      {
          QMainWindow::changeEvent(e);
          switch (e->type()) {
          case QEvent::LanguageChange:
              ui->retranslateUi(this);
              break;
          default:
              break;
          }
      }
      
      

      myrect.h:

      #include <QGraphicsRectItem>
      #include <QObject>
      
      class MyRect : public QObject, public QGraphicsRectItem {
      
      	Q_OBJECT
      
      	public:
      		enum { Type = UserType + 4484 };
      
      		MyRect(QGraphicsItem *parent = 0);
      		int type() const;
      
      	signals:
      
      	public slots:
      
      };
      

      myrect.cpp:

      MyRect::MyRect(QGraphicsItem *parent) : QGraphicsRectItem(parent) {
      
      
      	}
      
      
      	int MyRect::type() const {
      
      		//return value 70020
      		return Type;
      
      	}
      

      Attachments

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

        Activity

          People

            laknoll Lars Knoll
            anno Hans Müller
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes