Solved How to center qtooltip relative to a control?
-
This way, when the length of the prompt message changes, it cannot be centered relative to a control. Is there any other way?thanks!
QToolTip::showText(ui->txt->mapToGlobal(QPoint(200,0)),"message");
-
Hi
You can do something like thisvoid MainWindow::on_pushButton_pressed() { QString msg = "message that is longer"; QFontMetrics inf(QToolTip::font()); int msglen = inf.boundingRect(msg).width(); QToolTip::showText(ui->pushButton->mapToGlobal(QPoint( (ui->pushButton->width() / 2) - (msglen / 2),0)), msg ); }