Hi there!

I'm afraid it is not. The solid black background stays in my application. As you suggested, I continued our minimal error example in introducing the 3DTextItem and a dummy ProjectedItem. Sadly, still works.

main.cpp:

Qt Code:
  1. #include <QtGui>
  2. #include <QGLWidget>
  3. #include "textitem.h"
  4.  
  5. class CGLScene : public QGraphicsScene
  6. {
  7. protected:
  8. void drawBackground(QPainter *painter, const QRectF &rect)
  9. {
  10. glClearColor(1.0,1.0,0.0,1.0);
  11. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  12. }
  13. };
  14.  
  15. int main(int argc, char **argv){
  16. QApplication app(argc, argv);
  17. CGLScene scene;
  18.  
  19. view.setScene(&scene);
  20. view.setViewport(new QGLWidget);
  21.  
  22. CGL3dTextItem* item = new CGL3dTextItem("");
  23. item->setHTML("<font color=#FF0000>FAT TEST </font>");
  24.  
  25. scene.addItem(item);
  26.  
  27. QFont f;
  28. f.setPointSize(36);
  29. item->setFont(f);
  30. item->setFlag(QGraphicsItem::ItemIsMovable);
  31. //item->setCacheMode(QGraphicsItem::ItemCoordinateCache);
  32.  
  33. QTransform trans;
  34. trans.rotate(60, Qt::YAxis);
  35. item->setTransform(trans);
  36. item->setOpacity(1);
  37. view.show();
  38. return app.exec();
  39. }
To copy to clipboard, switch view to plain text mode 

textitem.h - a separate header file for moc to start up.
Qt Code:
  1. #ifndef TEXTITEM_H
  2. #define TEXTITEM_H
  3.  
  4. #include <QtGui>
  5. #include <QObject>
  6.  
  7. class CGL3dProjectedItem : public QObject, public QGraphicsItem
  8. { Q_OBJECT
  9. protected:
  10. virtual QRectF boundingRect() const {return shape().boundingRect();}
  11. virtual QPainterPath shape() const {QPainterPath p;QPolygonF polygon = mapToScene(this->childrenBoundingRect());p.addPolygon(polygon);return p;}
  12. virtual void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0) {}
  13. };
  14.  
  15. class CGL3dTextItem : public CGL3dProjectedItem
  16. { Q_OBJECT
  17. Q_PROPERTY(QObject* textitem READ getTextItem)
  18. Q_PROPERTY(QString text READ getText WRITE setText)
  19. Q_PROPERTY(QString html READ getHTML WRITE setHTML)
  20. Q_PROPERTY(QFont font READ getFont WRITE setFont)
  21. public:
  22. CGL3dTextItem(QString text) : CGL3dProjectedItem()
  23. {
  24. _textitem = new QGraphicsTextItem(text,this);
  25. _textitem->setTextInteractionFlags(Qt::TextBrowserInteraction);
  26. QTextOption textoption(Qt::AlignCenter);
  27. textoption.setWrapMode(QTextOption::WrapAtWordBoundaryOrAnywhere);
  28. _textitem->document()->setDefaultTextOption(textoption);
  29. _textitem->setCacheMode(QGraphicsItem::ItemCoordinateCache);
  30. //setHandlesChildEvents(true);
  31. }
  32. enum { Type = UserType+2};
  33. int type() const { return Type;}
  34. QObject* getTextItem() {return _textitem;}
  35. QString getText() {return _textitem->toPlainText();}
  36. void setText(QString plaintext) {_textitem->setPlainText(plaintext);TextChanged();}
  37. QString getHTML() {return _textitem->toHtml();}
  38. void setHTML(QString htmltext) {_textitem->setHtml(htmltext);TextChanged();}
  39. QFont getFont() {return _textitem->font();}
  40. void setFont(QFont f) {_textitem->setFont(f);TextChanged();}
  41. protected:
  42. void TextChanged()
  43. {
  44. // SetCenterPos(CGL3d(-_textitem->document()->size().width()/2,0,0));
  45. //qDebug() << "TextItem Center: " << CenterPos().toString();
  46. }
  47. private:
  48. QGraphicsTextItem* _textitem;
  49. };
  50.  
  51. #endif // TEXTITEM_H
To copy to clipboard, switch view to plain text mode 

So maybe the problem is hidden in the kind of transformation I am doing. I will investigate.

Thx

Joh