Important: Please read the Qt Code of Conduct -

Access violation QRubberBand

  • This code:

    void DSSImageView::mousePressEvent(QMouseEvent* e)
        rubberBandOrigin = e->pos();
        if (!rubberBand)
            rubberBand = new QRubberBand(QRubberBand::Rectangle, this);
        rubberBand->setGeometry(QRect(rubberBandOrigin, QSize()));
        emit Image_mousePressEvent(e);

    ends up with an access violation with a this->data value of 0xfdfdfdfd00000147 attempting to execute the following code in qwidget.h at line 768

    inline Qt::WindowType QWidget::windowType() const
    { return static_cast<Qt::WindowType>(int(data->window_flags & Qt::WindowType_Mask)); }


  • Are you sure that rubberBand has been initialized as nullptr ?

  • @Perdrix
    Dunno, you sure your rubberBand stays around, e.g. hasn't been deleted? Most likely would be an existing rubberBand pointing to rubbish or deleted widget? Also, assuming no threads, this will execute Image_mousePressEvent(e) directly, maybe that has a problem?

    In any case, it may not solve, but what you should show here is the stack trace during debug (it's in one of the debugger windows) at the time of the access violation, depending on content that might help narrow down. It may go all the way back to a particular line in your code.

  • Are you sure that rubberBand has been initialized as nullptr ?

  • @mranger90 BLUSH! That's so stupid of me! DOH! Slap-head award coming my way!


Log in to reply