PDA

View Full Version : QGraphicsTextItem Linkactivated not responding



Pancho
1st December 2009, 23:20
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.




class MenuPage:public QObject,public QGraphicsItemGroup
{
Q_OBJECT

public:
MenuPage();
~MenuPage()
void addClickabeLink(QString s);

public slots:
slot_linkactivated(const QString&);
};

MenuPage::
MenuPage()
{
setHandlesChildEvents ( false);
}

MenuPage::
~MenuPage()
{

}
MenuPage::
addClickabeLink(QString s)
{
clicktext = new QGraphicsTextItem(this);
addToGroup(clicktext);
clicktext->setTextInteractionFlags(Qt::LinksAccessibleByMouse |Qt::LinksAccessibleByKeyboard);
clicktext->setPlainText(s);
QObject::connect((QObject*)clicktext , SIGNAL(linkActivated(const QString&)),this,SLOT(slot_linkactivated(const QString&)) );
clicktext->setFont(dfont);
clicktext->setDefaultTextColor(Qt::blue);
clicktext->setPos(20,wheight+5);
wheight += clicktext->boundingRect().height() -5 ;
clicktext = NULL;
}

void MenuPage::
slot_linkactivated(const QString&)
{
.....
}

Pancho
2nd December 2009, 22:39
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.




class MenuPage:public QObject,public QGraphicsItemGroup
{
Q_OBJECT

public:
MenuPage();
~MenuPage()
void addClickabeLink(QString s);

public slots:
slot_linkactivated(const QString&);
};

MenuPage::
MenuPage()
{
setHandlesChildEvents ( false);
}

MenuPage::
~MenuPage()
{

}
MenuPage::
addClickabeLink(QString s)
{
clicktext = new QGraphicsTextItem(this);
addToGroup(clicktext);
clicktext->setTextInteractionFlags(Qt::LinksAccessibleByMouse |Qt::LinksAccessibleByKeyboard);
clicktext->setPlainText(s);
QObject::connect((QObject*)clicktext , SIGNAL(linkActivated(const QString&)),this,SLOT(slot_linkactivated(const QString&)) );
clicktext->setFont(dfont);
clicktext->setDefaultTextColor(Qt::blue);
clicktext->setPos(20,wheight+5);
wheight += clicktext->boundingRect().height() -5 ;
clicktext = NULL;
}

void MenuPage::
slot_linkactivated(const QString&)
{
.....
}


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