PDA

View Full Version : Composition



franco.amato
30th November 2009, 20:53
Is still not possible to use composition with a QPixmap in Qt 4..5.3 under windows?
Only QImage?
If not when it will be possible?

Best Regards,
Franco

wysota
30th November 2009, 21:16
Did you try it?

franco.amato
30th November 2009, 21:31
Did you try it?

No, the doc says that. How can I select a region over a Pixmap/Image using composition with the mouse?

Thank you in advance.
Best

wysota
30th November 2009, 22:15
No, the doc says that.
Maybe you should try it?


How can I select a region over a Pixmap/Image using composition with the mouse

Composition is about painting, not selecting things. For painting the selection you can use QPainter::CompositionMode_Xor if you want (or any other composition actually).

franco.amato
30th November 2009, 22:29
Maybe you should try it?



Composition is about painting, not selecting things. For painting the selection you can use QPainter::CompositionMode_Xor if you want (or any other composition actually).

I have to implement the mousePress/Move/ReleaseEvents right? Select a region and paint it?
Or I'm wrong? I have to select a region in the audio waveform .
Can I have a little example with some lines of code?

Best Regards,
Franco

wysota
30th November 2009, 22:38
You can do it many ways. QRubberBand docs has a nice example.

franco.amato
30th November 2009, 23:19
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() ) );

This is mainly my code:


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();
}


Where


QPoint startSelection;
QRubberBand* rb;

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

wysota
30th November 2009, 23:50
Did you initialize rb to 0 in the constructor?

franco.amato
1st December 2009, 00:52
Did you initialize rb to 0 in the constructor?

No this solved sorry for the trivial error.
A question how can I change the color of the Rubberband region?

Thankx,