Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 4

Qt-interest Archive, May 2008
Question on QFrame::setFrameStyle()


Message 1 in thread

<table cellspacing='0' cellpadding='0' border='0' ><tr><td style='font: inherit;'><P>Hello All</P>
<P>&nbsp;</P>
<P>I am developing a small application with QFrame as the base class ; When instantiating</P>
<P>this class&nbsp;- say class fooApp - I am invoking the method setFrameStyle(QFrame::Panel|</P>
<P>QFrame::Raised). So in this case the Frame appears exactly as expected when I execute</P>
<P>my application.</P>
<P>&nbsp;</P>
<P>However, when I overload define the&nbsp;method paintEvent() in the class fooApp - my </P>
<P>application needs to do some graphics operations - whatever graphics operations my</P>
<P>application performs happens correctly, but the Frame does not appear as a </P>
<P>Raised Panel. It appears more like a QFrame::NoFrame</P>
<P>&nbsp;</P>
<P>If I remove the overload definition of paintEvent() method, the Frame appears as raised </P>
<P>panel. </P>
<P>&nbsp;</P>
<P>I am missing out something small but vital. Could anyone help me out ?</P>
<P>&nbsp;</P>
<P>Thanks in advance</P>
<P>&nbsp;</P>
<P>Best regards</P>
<P>Srihari</P></td></tr></table><br>

      

--
 [ signature omitted ] 

Message 2 in thread

Hi Srihari, 
 
If you override a virtual method and want to perform the original function,
just call the base class' method. 
 
In this case, I suggest: 
 
void YourClass::paintEvent(QPaintEvent *event)
{
    // Draw the frame...
    QFrame::paintEvent(event);
 
    QPainter painter(this);
    painter.begin();
    // Your drawing goes here...
    painter.end();
}
 
Regards, 
 
Tony Rietwyk
 

-----Original Message-----
From: Srihari Parimi [mailto:srihari_parimi@xxxxxxxxx] 
Sent: Wednesday, 21 May 2008 17:07
To: qt-interest@xxxxxxxxxxxxx
Subject: Question on QFrame::setFrameStyle()



Hello All

 

I am developing a small application with QFrame as the base class ; When
instantiating

this class - say class fooApp - I am invoking the method
setFrameStyle(QFrame::Panel|

QFrame::Raised). So in this case the Frame appears exactly as expected when
I execute

my application.

 

However, when I overload define the method paintEvent() in the class fooApp
- my 

application needs to do some graphics operations - whatever graphics
operations my

application performs happens correctly, but the Frame does not appear as a 

Raised Panel. It appears more like a QFrame::NoFrame

 

If I remove the overload definition of paintEvent() method, the Frame
appears as raised 

panel. 

 

I am missing out something small but vital. Could anyone help me out ?

 

Thanks in advance

 

Best regards

Srihar  


-- To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with
"unsubscribe" in the subject or the body. List archive and information:
http://lists.trolltech.com/qt-interest/ 


Message 3 in thread

<table cellspacing='0' cellpadding='0' border='0' ><tr><td style='font: inherit;'><P>Hi Tony</P>
<P>&nbsp;</P>
<P>Thank you for the response and the solution. It has worked and sure enough</P>
<P>I missed out a simple Object Oriented programming concept :-)</P>
<P>&nbsp;</P>
<P>Best Regards</P>
<P>Srihari<BR><BR>--- On <B>Wed, 5/21/08, Tony Rietwyk <I>&lt;tony.rietwyk@xxxxxxxxxxxxxxxx&gt;</I></B> wrote:<BR></P>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: rgb(16,16,255) 2px solid">From: Tony Rietwyk &lt;tony.rietwyk@xxxxxxxxxxxxxxxx&gt;<BR>Subject: RE: Question on QFrame::setFrameStyle()<BR>To: qt-interest@xxxxxxxxxxxxx<BR>Date: Wednesday, May 21, 2008, 1:16 PM<BR><BR>
<DIV id=yiv432904195>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>Hi Srihari, </FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>If you override a virtual method and want to perform the original function, just call the base class' method. </FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>In this case, I suggest: </FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>void YourClass::paintEvent(QPaintEvent *event)</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>{</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008>&nbsp;&nbsp;&nbsp; <FONT face=Arial color=#0000ff size=2>// Draw the frame...</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008>&nbsp;&nbsp;&nbsp; <FONT face=Arial color=#0000ff size=2>QFrame::paintEvent(event);</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=140083907-21052008>&nbsp;&nbsp;&nbsp; <FONT face=Arial color=#0000ff size=2>QPainter painter(this);</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008>&nbsp;&nbsp;&nbsp; <FONT face=Arial color=#0000ff size=2>painter.begin();</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008>&nbsp;&nbsp;&nbsp; <FONT face=Arial color=#0000ff size=2>// Your drawing goes here...</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>&nbsp;&nbsp;&nbsp; painter.end();</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>}</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>Regards, </FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>Tony Rietwyk</FONT></SPAN></DIV>
<DIV><SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<BLOCKQUOTE style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left><FONT face=Tahoma size=2>-----Original Message-----<BR><B>From:</B> Srihari Parimi [mailto:srihari_parimi@xxxxxxxxx] <BR><B>Sent:</B> Wednesday, 21 May 2008 17:07<BR><B>To:</B> qt-interest@xxxxxxxxxxxxx<BR><B>Subject:</B> Question on QFrame::setFrameStyle()<BR><BR></FONT></DIV>
<TABLE cellSpacing=0 cellPadding=0 border=0>
<TBODY>
<TR>
<TD>
<P>Hello All</P>
<P>&nbsp;</P>
<P>I am developing a small application with QFrame as the base class ; When instantiating</P>
<P>this class&nbsp;- say class fooApp - I am invoking the method setFrameStyle(QFrame::Panel|</P>
<P>QFrame::Raised). So in this case the Frame appears exactly as expected when I execute</P>
<P>my application.</P>
<P><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</P>
<P>However, when I overload define the&nbsp;method paintEvent() in the class fooApp - my </P>
<P>application needs to do some graphics operations - whatever graphics operations my</P>
<P>application performs happens correctly, but the Frame does not appear as a </P>
<P>Raised Panel. It appears more like a QFrame::NoFrame</P>
<P><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</P>
<P>If I remove the overload definition of paintEvent() method, the Frame appears as raised </P>
<P>panel. </P>
<P><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</P>
<P>I am missing out something small but vital. Could anyone help me out ?</P>
<P><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</P>
<P>Thanks in advance</P>
<P><FONT face=Arial color=#0000ff size=2></FONT>&nbsp;</P>
<P>Best regards</P>
<P>Srihar<SPAN class=140083907-21052008><FONT face=Arial color=#0000ff size=2>&nbsp;&nbsp;</FONT></SPAN></P></TD></TR></TBODY></TABLE><BR>-- To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with "unsubscribe" in the subject or the body. List archive and information: http://lists.trolltech.com/qt-interest/ </BLOCKQUOTE></DIV></BLOCKQUOTE></td></tr></table><br>



      

--
 [ signature omitted ]