PtTrend or PtMTrend

Hello
Do you have anybody fully and correctly working Trend widget code(in PhAB or without PhAB) ? Could you publish it here or send me it on email? I have still a problem how to use this widget.
Thanks a lot!

what are you trying to do exactly? if you are having trouble seeing the trend then the reason is probably because you need to put PtFlush(); and PtBkgdHandlerProcess(); in the callback which updates these widgets.

I re-made some source code with PtTrend widget to PtMTrend (I found it on the web). With PtTrend widget it works perfectly. I have a problem with adding data to PtMTrend widget. When I use PtMTrendChangeData program falls down with memory fault. Why? What is wrong?

#include <Pt.h> 
#include <math.h> 

#define START_X         .0 
#define WIDTH         628 
#define SAMPLES         628 
#define TRENDS         2 
#define HEIGHT         200 
#define STEP            (2. / HEIGHT) 

PtWidget_t *trend; 

int main () 
{ 
   int i; 
   double x, y; 
   PtWidget_t *window;
   PtArg_t args[10]; 
   PhDim_t dim; 
   int trend_data [SAMPLES * TRENDS]; 
   PtMTrendAttr_t trend_info;
    
   if (PtInit(NULL) == -1) 
      return -1; 

   dim.w = WIDTH; 
   dim.h = HEIGHT; 
   PtSetArg(&args[0], Pt_ARG_DIM, &dim, 0); 

   if ((window = PtCreateWidget(PtWindow, NULL, 1, &args[0])) == NULL) 
      return -1; 
 
	i=1;   
	PtSetArg(&args[i++], Pt_ARG_MTREND_FLAGS, Pt_MTREND_GRID_NONE , Pt_MTREND_GRID_MASK ); 
	PtSetArg(&args[i++],Pt_ARG_MTREND_FLAGS , Pt_MTREND_HORZ_L2R , Pt_MTREND_DIRECTION_MASK ); 
	PtSetArg(&args[i++],Pt_ARG_MTREND_FLAGS , Pt_MTREND_BLIT , 0 ); 
	PtSetArg(&args[i++],Pt_ARG_MTREND_FLAGS , Pt_MTREND_ALWAYS_SCROLL , 0 ); 
	PtSetArg(&args[i++],Pt_ARG_MTREND_N_SAMPLES , SAMPLES , 0 ); 

	PtSetArg(&args[i++],Pt_ARG_MTREND_N_GRAPHS , TRENDS , 0 ); 
	
	trend_info.state= Pt_MTREND_STATE_SHOWN; 
	trend_info.color = Pg_GREEN; 
	trend_info.line_thickness = 2; 
	trend_info.min = -(HEIGHT / 2); 
	trend_info.max = (HEIGHT / 2); 
	trend_info.join_type = Pg_MITER_JOIN; 
	PtSetArg(&args[i++], Pt_ARG_MTREND_GRAPH_ATTR, &trend_info , 1); 

    
   if ((trend = PtCreateWidget(PtMTrend, window, i, args)) == NULL) 
      return -1; 

   for (i = 0, x = START_X; i < SAMPLES; i++, x += STEP) 
   { 
      y = sin(x)/ STEP; 
      trend_data[i] = y; 
   } 
    
   for (i = 0, x = START_X; i < SAMPLES; i++, x += STEP) 
   { 
      y = sin(4 * x) / STEP / 4; 
      trend_data[SAMPLES + i] = y; 
   } 
    
   PtRealizeWidget(window); 
   PtMTrendChangeData(trend,0, trend_data, 0, SAMPLES); 
   PtMainLoop(); 
    
   return 0; 
}

did you solve your problem?

Notice that QNX is going to deprecate Photon as per the 6.5 SP1 Release Notes. Photon today is still supported but it’s not further developed and will probably disappear from the next “big” QNX release. So if you are starting a new project today I’d recommend you look at Qt. Qt officially supports QNX.

My problem was silimar, It has been solved just by adding this line before PtSetArg(&args[i++], Pt_ARG_MTREND_GRAPH_ATTR, &trend_info , 1):

trend_info.draw_f=NULL;