0
votes

OK. So, I have a form in which there is Qt's Tab Widget. And, I have a custom widget in which I have Qt's Webkit.

Now, I want to change the text in the parent tab of my custom widget when the website changes. I have got the function for the titleChanged signal of the webkit, but I am not sure how to access its parent tab to change that tab's text.

I would like to access the custom widget's parent tab, and NOT the current tab in the tab widget. This way, the text of the tab changes even if it is not selected.

I have no idea on how to do this, which is why I cannot post any code. The empty titleChanged signal code is not available to me, so I cannot post that as well.

Thank You.

1

1 Answers

0
votes

Since you want to modify your custom widget's parent, when calling your custom widget constructor pass as parameter its parent and connect the signal:

CustomWidget(QWidget * parent) : CustomWidgetBaseClass(parent)
{
    connect(this->webkit, SIGNAL(titleChanged(const QString &)), parent, SLOT(setWindowTitle(const QString &));
}

This also guarantee your CustomWidget being deallocated when CustomWidgetBaseClass is destructed.

If you have to connect it later on instead on construction, you can always get the parent using parentWidget() const method and connect it later, but always set the parent on construction, that is how Qt is meant to be used

Hope that helps!