Results 1 to 5 of 5

Thread: How draw extra border on QGraphicsTextItem?

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    May 2006
    Posts
    788
    Thanks
    49
    Thanked 48 Times in 46 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default How draw extra border on QGraphicsTextItem?

    Qt Code:
    1. /*
    2. incomming QDomElement
    3. <divtext rotate="90" zindex="2" left="115" top="25" large="300" hight="400" >
    4. <param font="arial" color="#0000ff" size="30">Scribble XHTML Floating DIV box width:300px height:400px top:25px left:115px</param>
    5. </divtext>
    6. */
    7.  
    8. class FloatText : public QGraphicsTextItem
    9. {
    10. Q_OBJECT
    11. public:
    12. FloatText( QDomElement xmlstream , QGraphicsItem *parent, QGraphicsScene *scene )
    13. : QGraphicsTextItem(parent, scene)
    14. {
    15. modus = MODUS_MOVE;
    16. root = xmlstream;
    17. moveBy(GetInt("left"),GetInt("top"));
    18. rotate(GetInt("rotate"));
    19. f = QFont();
    20. int FontSize = root.firstChildElement("param").attributeNode("size").value().toInt();
    21. if (FontSize > 9) {
    22. f.setPixelSize(FontSize);
    23. } else {
    24. f.setPixelSize(10);
    25. }
    26. f.setFamily( root.firstChildElement("param").attributeNode("font").value() );
    27. setDefaultTextColor ( root.firstChildElement("param").attributeNode("color").value() );
    28. human = root.firstChildElement("param").text();
    29. setTextWidth ( GetInt("large") );
    30. setPlainText ( human );
    31. setFont(f);
    32. setZValue( GetInt("zindex") + 300 ); /* to make border - */
    33. SetMoveItem();
    34. QObject::connect(scene, SIGNAL(selectionChanged()), this, SLOT(WakeUpHere()));
    35. /////// ensureVisible(QRectF(GetInt("left"),GetInt("top"),GetInt("large"),GetInt("hight")),80,80);
    36. }
    37.  
    38. void paint(QPainter *painter,const QStyleOptionGraphicsItem *option,QWidget *widget)
    39. {
    40. painter->drawRect (-2,-2,GetInt("large") + 4,8); /* GetInt("hight") + 4 border 2px out side overflow*/
    41. update();
    42. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.