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

Qt-interest Archive, July 2004
Mac OSX text Problems


Message 1 in thread

Hello Everybody

I have some problems with rendering Text in Mac OSX Jaguar. I have 
compiled it with xcodebuild with macx-pbuilder makespec, using qt 3.3.2.

NOTE: The program works fine under RedHat and WinXP.

1. OpenGL Widget:
  	renderText () does not render any text, whereas rest of the OpenGL 
parts are drawn correctly.

	For example, a code like this renders nothing

QString m_name = "teststr";
renderText(- 0.5, 0.1,0.0,m_name.latin1());

None of the OpenGL renderText works.

2. QPixmap renders as a blackbox:

Im trying to put a vertical QLabel. But does not work. It is rendered as 
a Black Box.


QPixmap getRotatedText(QString str)
{
   QPainter		p;
   QRect			r;			/* rectangle covering new text/pixmap in virtual 
coordinates */
   QWMatrix		um;
   QFontMetrics	fm(fontMetrics());

   r = fm.boundingRect(str);

   /* rectangle covering text */
   //  QRect	rr(r.top(), r.left(), r.height(), r.width());
   QRect	rr(r.top()+3, r.left()+3, r.height()+3, r.width()+3);
   int		textYPos;			/* distance from boundingRect y pos to baseline */
   int		textXPos;			/* distance from boundingRect x pos to text start */

   textYPos = -rr.y();
   textXPos = -rr.x();

   int x = rr.width();
   int y = rr.height();

   rr.moveTopLeft(QPoint(-rr.width() / 2, -rr.height() / 2));

   int		rb = rr.bottom();
   int		rt = rr.top();
   int		rl = rr.left();
   int		_rr = rr.right();
   QPixmap pm(x, y);			/* off-screen drawing pixmap */

   pm.fill(SPtable->horizontalHeader()->paletteBackgroundColor());

   p.begin(&pm);
   um.translate(x / 2, y / 2); /* 0,0 is center */
   um.rotate(-90);
   p.setFont(font());			/* use widget font */
   p.setWorldMatrix(um);
   p.drawText(-y / 2, x / 2 - 1, str);
   p.end();

   return pm;
}


Can anyone tell me how to solve it ?

cheers
Sathya