How to change the header of a QHelpContentWidget

  • Hello,

    I'm using the QHelpEngine within my software and have created a dialog that sports the QHelpContentWidget on the left to display the tree view of the help and a QTextBrowser on the right to display the actual help contents. Since QHelpContentWidget inherits QTreeView, I figured it should be possible to show the header and set the header data to whatever I want it to be, in my case, I'd like it to be "Contents".

    I make sure that the headerView is visible:


    Then I am trying two options: 1 is to access the model through the content widget:

    QHelpContentWidget* pContentWidget = pHelpEngine->contentWidget();
    pContentWidget->header()->model()->setHeaderData(0, Qt::Horizontal, QString(tr("Contents")), Qt::DisplayRole);
    qDebug() << pContentWidget->model()->headerData(0, Qt::Horizontal);

    and 2 accessing the model from the separate access function in the QHelpEngine:

    QHelpContentModel* pContentModel = pHelpEngine->contentModel();
    pContentModel()->setHeaderData(0, Qt::Horizontal, QString(tr("Contents")), Qt::DisplayRole);
    qDebug() << pContentModel->headerData(0, Qt::Horizontal);

    In both cases, setHeaderData returns 'false' and the header is not updated but displays what seems to be the default value '1'.

    Any ideas, what I am missing here?


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.