Trolltech Home | Qtopia-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 1

Qtopia-interest Archive, December 2006
Drawing functionality on frame giving problem


Message 1 in thread

Hi All,
I have created a Mainwindow (widget).
In that i created two qframes.
I wanted to draw lines in side the frame1 and frame 2.
As everybody knows Qframe is inherited by Qwidget i thought i could draw
lines in side it.

I have one button in the window(Main widget )also.
I created all these using qt designer

So in the button click function i tryed to implement it.

What i did is

Note : in the function ECGDrawingarea it is a frame inside the window
void MainProcessingFormImpl::MP_MORE_BUT_Clicked()
{

       QPainter  *ecgpainter;


     // QColor red(255,0,0);
      //Qpen redpen(red,1,SolidLine);
      //ecgpainter.setPen(redpen);
      ecgpainter->begin( (QWidget*)this->ECGDrawingarea ); //Type cast from
frame to qwidget
      qWarning( "\n Test1 " );
   //   ecgpainter->setWindow (0,0,200,200)
      qWarning( "\n Test2 " );
      ecgpainter->setPen(Qt::red);
      qWarning( "\n Test3 " );
      ecgpainter->drawLine(20,20,100,100);
      qWarning( "\n Test4 " );
      ecgpainter->end();
      qWarning( "\n Test5 " );

}

But when i run the application and
when i click the button it is giving segmentation fault error message.

Kindly suggest me what i am doing wrong.

Thanks in advance.

Regards
Harsha

Message 2 in thread

Am 01.12.2006 um 16:43 schrieb harshavardhanreddy mandeepala:

> Hi All,
>


QPainter *ecgpainter is an unitialized pointer. Now take a look at  
your code and consider what happens if you access uninitalized  
pointers...



> Note : in the function ECGDrawingarea it is a frame inside the window
> void MainProcessingFormImpl::MP_MORE_BUT_Clicked()
> {
>
>        QPainter  *ecgpainter;
>
>

^^^hint ^^^^

h.

--
 [ signature omitted ] 

Message 3 in thread

Hi Holger,

Thanks for ur reply.

I modified as

 QPainter *ecgpainter;
 ecgpainter = new QPainter;

Now it is working fine.

But when i try to do as follows it is giving error message as
error: 'Qpen' was not declared in this scope
But i include qpen.h .

My code is

void MainProcessingFormImpl::MP_MORE_BUT_Clicked()
{

     QPainter *ecgpainter;
     ecgpainter = new QPainter;

     Qpen *redpen;
     QColor *rgbcolor=new QColor(200,200,0);
     redpen = new Qpen(rgbcolor,1,SolidLine);

     //   redpen->setColor(rgbcolor);

      ecgpainter->begin( (QWidget*)this->ECGDrawingarea );

   //   ecgpainter->setWindow (0,0,200,200)

     // ecgpainter->setPen(Qt::red);

      ecgpainter->setPen(redpen);
      ecgpainter->drawLine(20,20,100,100);

      ecgpainter->end();


}


Am i doing anything wrong.
I am using qtopia-2.1.1 and qt-2.3.10
Is it the problem of qt itself.

Thanks a lot for ur help.

Regards,
Harsha

--
 [ signature omitted ]