Originally Posted by
wysota
You can do it many ways.
QRubberBand docs has a nice example.
dear wysota I tried to implement the rubberBand example but I always get a crash on the line
rb
->setGeometry
( QRect( startSelection,
QSize() ) );
rb->setGeometry( QRect( startSelection, QSize() ) );
To copy to clipboard, switch view to plain text mode
This is mainly my code:
{
if( pe->button() == Qt::LeftButton )
{
pe->accept();
startSelection = pe->pos();
qDebug() << pe->pos();
if( !rb )
rb
->setGeometry
( QRect( startSelection,
QSize() ) );
rb->show();
}
else
pe->ignore();
}
void WaveWidget::mousePressEvent( QMouseEvent* pe )
{
if( pe->button() == Qt::LeftButton )
{
pe->accept();
startSelection = pe->pos();
qDebug() << pe->pos();
if( !rb )
rb = new QRubberBand( QRubberBand::Rectangle, this );
rb->setGeometry( QRect( startSelection, QSize() ) );
rb->show();
}
else
pe->ignore();
}
To copy to clipboard, switch view to plain text mode
Where
QPoint startSelection;
QRubberBand* rb;
To copy to clipboard, switch view to plain text mode
are private members of my WaveWidget class.
I don't know where my code fails if I exactly copied the code of the doc.
If I comment the setGeometry now it craches on the show method.
Do you have an idea?
Best Regards
Bookmarks