Results 1 to 2 of 2

Thread: QGraphicsTextItem Linkactivated not responding

  1. #1
    Join Date
    Dec 2009
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default QGraphicsTextItem Linkactivated not responding

    I am not able to get the linkactivated signal of QGraphicsTextItem with the below code.When ever I click on the text only a dashed outline box comes around the text.

    Qt Code:
    1. class MenuPage:public QObject,public QGraphicsItemGroup
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MenuPage();
    7. ~MenuPage()
    8. void addClickabeLink(QString s);
    9.  
    10. public slots:
    11. slot_linkactivated(const QString&);
    12. };
    13.  
    14. MenuPage::
    15. MenuPage()
    16. {
    17. setHandlesChildEvents ( false);
    18. }
    19.  
    20. MenuPage::
    21. ~MenuPage()
    22. {
    23.  
    24. }
    25. MenuPage::
    26. addClickabeLink(QString s)
    27. {
    28. clicktext = new QGraphicsTextItem(this);
    29. addToGroup(clicktext);
    30. clicktext->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::LinksAccessibleByKeyboard);
    31. clicktext->setPlainText(s);
    32. QObject::connect((QObject*)clicktext , SIGNAL(linkActivated(const QString&)),this,SLOT(slot_linkactivated(const QString&)) );
    33. clicktext->setFont(dfont);
    34. clicktext->setDefaultTextColor(Qt::blue);
    35. clicktext->setPos(20,wheight+5);
    36. wheight += clicktext->boundingRect().height() -5 ;
    37. clicktext = NULL;
    38. }
    39.  
    40. void MenuPage::
    41. slot_linkactivated(const QString&)
    42. {
    43. .....
    44. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by Pancho; 1st December 2009 at 23:32.

  2. #2
    Join Date
    Dec 2009
    Posts
    2
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Wink Re: QGraphicsTextItem Linkactivated not responding

    Quote Originally Posted by Pancho View Post
    I am not able to get the linkactivated signal of QGraphicsTextItem with the below code.When ever I click on the text only a dashed outline box comes around the text.

    Qt Code:
    1. class MenuPage:public QObject,public QGraphicsItemGroup
    2. {
    3. Q_OBJECT
    4.  
    5. public:
    6. MenuPage();
    7. ~MenuPage()
    8. void addClickabeLink(QString s);
    9.  
    10. public slots:
    11. slot_linkactivated(const QString&);
    12. };
    13.  
    14. MenuPage::
    15. MenuPage()
    16. {
    17. setHandlesChildEvents ( false);
    18. }
    19.  
    20. MenuPage::
    21. ~MenuPage()
    22. {
    23.  
    24. }
    25. MenuPage::
    26. addClickabeLink(QString s)
    27. {
    28. clicktext = new QGraphicsTextItem(this);
    29. addToGroup(clicktext);
    30. clicktext->setTextInteractionFlags(Qt::LinksAccessibleByMouse|Qt::LinksAccessibleByKeyboard);
    31. clicktext->setPlainText(s);
    32. QObject::connect((QObject*)clicktext , SIGNAL(linkActivated(const QString&)),this,SLOT(slot_linkactivated(const QString&)) );
    33. clicktext->setFont(dfont);
    34. clicktext->setDefaultTextColor(Qt::blue);
    35. clicktext->setPos(20,wheight+5);
    36. wheight += clicktext->boundingRect().height() -5 ;
    37. clicktext = NULL;
    38. }
    39.  
    40. void MenuPage::
    41. slot_linkactivated(const QString&)
    42. {
    43. .....
    44. }
    To copy to clipboard, switch view to plain text mode 
    The problem was at setting the text.I am using setPlainText() instead of setHtml() and also see that the text is in <a href="<link>">text</a> format

Similar Threads

  1. not drag and drop on a QGraphicsTextItem
    By jano_alex_es in forum Qt Programming
    Replies: 4
    Last Post: 19th October 2009, 08:49
  2. cursor in qgraphicstextitem
    By Noxxik in forum Qt Programming
    Replies: 0
    Last Post: 15th March 2009, 12:04
  3. Problem on set QGraphicsTextItem write protect.
    By patrik08 in forum Qt Programming
    Replies: 1
    Last Post: 22nd July 2007, 20:53
  4. QGraphicsTextItem: handling cursor position change
    By Angelo Moriconi in forum Qt Programming
    Replies: 2
    Last Post: 30th January 2007, 10:42
  5. QGraphicsTextItem size
    By Angelo Moriconi in forum Qt Programming
    Replies: 1
    Last Post: 26th January 2007, 08:34

Tags for this Thread

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.