I'm using qt3 under linux (Debian). I have a large project , but I have a problem in the interface ,, in my project I need a frame for writing on it ,, and and a button for erasing all what was written , and another button that acts as an eraser and of course a button for re-writing on the frame.
The problem was once I write on the frame and erase it ( using QWidget::erase())
and another window come over my window ,, all what was erased before is draw on the frame
This is the constructor of my class
code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
TextFrame::TextFrame(QWidget *parent) : QFrame(parent)
{
QPixmap a ( QPixmap("Text.png") ) ;
_buffer = a ; // _buffer is private variable of tyep QPixmap
CounterOfPoint = 0 ;
_currentSize=0;
}
void TextFrame::mousePressEvent( QMouseEvent * e )
{
// I want to write on frame :
if ( erase == false )
{
_last = e->pos();
// Add point to array of points
Points [CounterOfPoint].x = _last.x() ;
Points [CounterOfPoint].y = _last.y() ;
CounterOfPoint++;
pen.setWidth ( _currentSize) ;
pen.setColor (_currentColor);
windowpainter.begin (this) ;
bufferpainter.begin(& _buffer) ;
windowpainter.setPen (pen);
bufferpainter.setPen (pen);
windowpainter.drawPoint(_last);
windowpainter.end() ;
bufferpainter.end () ;
}
// erase from frame :
else
CheckEraseSize(e);
} //end if
code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
and the is the resizeEvent function ,,
void TextFrame :: resizeEvent ( QResizeEvent * event)
{
QPixmap save ( _buffer ) ;
_buffer.resize ( event -> size () ) ;
bitBlt ( &_buffer , 0, 0 , &save ) ;
}
EraseCheckSize(e) is jsut a function that checks the size choosed by the user and then use:
QWidget::erase(Region);
for erasing all the frame I could use this code and the prblem disappears , but I don't know how to do if I would only earase some of my drawing not every thing: