Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

ToolTip is not showing text



  • Hi,

    I have problems with some of mine tooltips in my application.
    The tooltips rectangle is showed correctly, but there is no text into it although I've set it using setToolTip.
    The QToolButton have been put in a toolbar. That's the code:

        tileVertical = new QToolButton(ui->toolBar);
        tileVertical->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
        tileVertical->setIcon(QIcon(":/rec/img/TileH.png"));
        tileVertical->setIconSize(QSize(32,32));
        tileVertical->setStyleSheet("background-color:black; color:white");
        tileVertical->setText(tr("Posiziona verticalmente"));
        tileVertical->setToolTip(tr("Posiziona verticalmente"));
        tileVertical->setFocusPolicy(Qt::NoFocus);
        ui->toolBar->addWidget(tileVertical);
        connect(tileVertical, SIGNAL(clicked()), this, SLOT(on_actionTileVertical_triggered()));
    

    Any advice on this? It would be very helpful.

    Thanks in advance


    Davide Salvetti



  • @davidesalvetti said in ToolTip is not showing text:

    Any advice on this?

    That is because of StyleSheet.



  • @Ratzz Thank you for the answer.

    Changing this line:

    tileVertical->setStyleSheet("background-color:black; color:white");

    to this:

    tileVertical->setStyleSheet("QToolButton{background-color:black; color:white;}QToolButton QWidget{color:black;}");

    worked for me.


Log in to reply