Results 1 to 5 of 5

Thread: QGraphicsTextItem dont open Link /bug?

  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 QGraphicsTextItem dont open Link /bug?

    Why QGraphicsTextItem dont open link? is this a bug?

    or is here other method to append QGraphicsTextItem to scene?

    a minimal build main.cpp is attach here.

    Qt Code:
    1. /* load central widget */
    2. void Load_Connector()
    3. {
    4. view = new QGraphicsView(this); /* QMainWindow */
    5. Vbar = view->verticalScrollBar();
    6. Hbar = view->horizontalScrollBar();
    7. QGraphicsScene *scene = new QGraphicsScene(view);
    8. scene->setSceneRect( 0, 0, 1000, 1000 );
    9. view->setScene(scene);
    10. setCentralWidget(view);
    11. /* set tag xhtml to projekt xml tag */
    12. QString qthtml = "<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:8pt;\"><span style=\" font-family:'Impact'; font-size:26pt; color:#5555ff;\">H</span>"
    13. "<span style=\" font-family:'Impact'; font-size:26pt; color:#0000ff;\">e</span>"
    14. "<span style=\" font-family:'Impact'; font-size:26pt; color:#ff0000;\">l</span>"
    15. "<span style=\" font-family:'Impact'; font-size:26pt; color:#ffff00;\">l</span>"
    16. "<span style=\" font-family:'Impact'; font-size:26pt; color:#ffaa7f;\">o</span>"
    17. "<span style=\" font-family:'Impact'; font-size:26pt;\"> </span>"
    18. "<span style=\" font-family:'Impact'; font-size:26pt; color:#00ff00;\">color</span>"
    19. "<span style=\" font-family:'Impact'; font-size:26pt; color:#ff0000;\"> world</span>"
    20. "<span style=\" font-family:'Impact'; font-size:26pt;\">!</span>"
    21. "<a href=\"http://wiki.qtcentre.org/index.php?title=QGraphicsTextItem\"><span style=\" text-decoration: underline; color:#0000ff;\">link</span></a> </p> ";
    22.  
    23. QGraphicsTextItem* txtarea = scene->addText("");
    24. txtarea->setHtml(qthtml);
    25. txtarea->setOpenExternalLinks(true); /* set clickable */
    26. txtarea->setFlag(QGraphicsItem::ItemIsMovable);
    27. ViewPoint(0); /* scroll area stay 0 to init! */
    28. }
    To copy to clipboard, switch view to plain text mode 
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGraphicsTextItem dont open Link /bug?

    Qt Code:
    1. txtarea->setTextInteractionFlags(Qt::LinksAccessibleByMouse); // | Qt::LinksAccessibleByKeyboard
    To copy to clipboard, switch view to plain text mode 
    J-P Nurmi

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

    Default Re: QGraphicsTextItem dont open Link /bug?

    Quote Originally Posted by jpn View Post
    Qt Code:
    1. txtarea->setTextInteractionFlags(Qt::LinksAccessibleByMouse); // | Qt::LinksAccessibleByKeyboard
    To copy to clipboard, switch view to plain text mode 
    OK .. tanks i found ... but is not possibel to make it ItemIsMovable and
    Qt::TextBrowserInteraction on same modus? i must split modus to
    view edit preview , correct or is this mistake?


    Qt Code:
    1. QGraphicsTextItem* txtarea = new QGraphicsTextItem(0,scene);
    2. txtarea->setHtml(qthtml);
    3. txtarea->setOpenExternalLinks(true); /* set clickable */
    4. ////txtarea->setTextInteractionFlags(Qt::TextEditorInteraction);
    5. txtarea->setTextInteractionFlags(Qt::TextBrowserInteraction);
    6. txtarea->setFlag(QGraphicsItem::ItemIsMovable);
    7. txtarea->ensureVisible(QRectF(10,10,200,200),80,80);
    8. txtarea->moveBy(100,200);
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QGraphicsTextItem dont open Link /bug?

    Quote Originally Posted by patrik08 View Post
    but is not possibel to make it ItemIsMovable and
    Qt::TextBrowserInteraction on same modus?
    Well, setting Qt::TextBrowserInteraction makes the item to handle mouse move events as selection. You should still be able to move the item by grabbing from its edges.
    J-P Nurmi

  5. The following user says thank you to jpn for this useful post:

    patrik08 (7th July 2007)

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

    Default Re: QGraphicsTextItem dont open Link /bug?

    Now i have adjusted and it paint correct ..
    but ..

    setFlag(QGraphicsItem::ItemIsMovable, true);
    setFlag(QGraphicsItem::ItemIsSelectable, true);

    stay on old place... why?

    how i can handle ItemIsMovable area?

    Qt Code:
    1. QRectF boundingRect() const
    2. {
    3. /*
    4.   int width; html div area
    5.   int hight; html div area
    6.   moveBy(GetInt("left"),GetInt("top"));
    7.   */
    8. QRectF now = QGraphicsTextItem::boundingRect(); /* actual setting */
    9. return QGraphicsTextItem::boundingRect().adjusted(-2,-2, width - now.width() , hight - now.height() );
    10. }
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. add link that open web browser on unix
    By asafb in forum Qt Programming
    Replies: 7
    Last Post: 25th January 2009, 21:55
  2. How to open external page link using tabwidget
    By jyoti in forum Qt Programming
    Replies: 2
    Last Post: 13th November 2006, 10:43
  3. LINK : fatal error LNK1181: can't open 'delayimp.lib'
    By fcamlar in forum Installation and Deployment
    Replies: 10
    Last Post: 7th July 2006, 13:04

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.