Qt Forum - programming with C++ and Qt
Register Calendar Members List Team Members Search Frequently Asked Questions Go to the Main Page

Qt Forum - programming with C++ and Qt » QtForum.org » Qt » Qt Designer » Problem in QPainter » Hello Guest [Login|Register]
Last Post | First Unread Post Print Page | Recommend to a Friend | Add Thread to Favorites
Post New Thread Post Reply
Go to the bottom of this page Problem in QPainter
Author
Post « Previous Thread | Next Thread »
R.M
Assistant


Registration Date: 23.02.2008
Posts: 8

Level: 8 [?]
Experience: 666
Next Level: 674

8 points of experience needed for next level

traurig Problem in QPainter Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

Hello everyone ,,

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 unhappy

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


paintEvent Function

code:
1:
2:
3:
4:
5:
6:
void TextFrame :: paintEvent(QPaintEvent*)
{ 
    bitBlt(this , 0 , 0 , &_buffer) ; 
    
}


mousePressEvent and mouseMoveEvent approximately the same

code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
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:
code:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
void  TextFrame :: EraseAll()
{
              CounterOfPoint = 0 ; 
	     
            
	     _buffer = *(QWidget::erasePixmap ());
	
	
              QWidget::setErasePixmap (_buffer) ;
	      
	      
	
}


Any help is greatly appreciated..

This post has been edited 1 time(s), it was last edited by R.M: 16.04.2008 22:10.

16.04.2008 21:50 R.M is offline Send an Email to R.M Search for Posts by R.M Add R.M to your Buddy List
R.M
Assistant


Registration Date: 23.02.2008
Posts: 8

Level: 8 [?]
Experience: 666
Next Level: 674

8 points of experience needed for next level

Thread Starter Thread Started by R.M
Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

up unhappy
18.04.2008 13:59 R.M is offline Send an Email to R.M Search for Posts by R.M Add R.M to your Buddy List
R.M
Assistant


Registration Date: 23.02.2008
Posts: 8

Level: 8 [?]
Experience: 666
Next Level: 674

8 points of experience needed for next level

Thread Starter Thread Started by R.M
Reply to this Post Post Reply with Quote Edit/Delete Posts Report Post to a Moderator       Go to the top of this page

up ..

Am I write my problem in a wrong place ?

This post has been edited 1 time(s), it was last edited by R.M: 04.05.2008 19:30.

28.04.2008 19:18 R.M is offline Send an Email to R.M Search for Posts by R.M Add R.M to your Buddy List
Tree Structure | Board Structure
Jump to:
Post New Thread Post Reply
Qt Forum - programming with C++ and Qt » QtForum.org » Qt » Qt Designer » Problem in QPainter

views today: 10.109 | views yesterday: 17.520 | total views: 10.243.478


Klebekork Shop - Linux Shop - Kontaktanzeigen - Linux Forum -  SMS Gewinnspiel -  Hotels -  Stadtpläne -  Branchenbuch & Stadtplan

Branchenbuch Österreich - Branchenbuch Niederlande - Portugal Branchenverzeichnis - Spanien Branchenverzeichnis 
Telefonbuch - Branchenbuch Frankreich