PDA

View Full Version : Hot to set the tooltip of button



santosh.kumar
31st October 2007, 13:55
hi

I have one application that contains one MainWindow...MainWindow contains some dialog and some button on the dialog.....When i open any dialog from menu of this MainWindow..
it doesn't show tooltip of Button...

But when i use
DialogClass->show(); it shows the tooltip...But it here setModal(false) by default...
When i use DialogClass->setModal(true);
DialogClass->show(); Tooltip is not working while open the dialog...but when I click on this dialog ...tooltip is coming....I donot why this is happening...

I have to use tooltip features on this dialog and setModal(true) both simultaneously....
But on starting time means when i open the dialog tooltip is not coming...when i use setModal(true);....if m not using setModal(false) tooltip is coming...


please help me if anybody have idea

jpn
31st October 2007, 14:42
You know, you could simply use QDialog::exec() to trigger modal dialogs. I'm not 100% sure if this is the case, but you can enable tooltips for inactive windows like this:

dialog.setAttribute(Qt::WA_AlwaysShowToolTips);

santosh.kumar
1st November 2007, 12:54
You know, you could simply use QDialog::exec() to trigger modal dialogs. I'm not 100% sure if this is the case, but you can enable tooltips for inactive windows like this:

dialog.setAttribute(Qt::WA_AlwaysShowToolTips);

I m using Qt4.2.2...

I used this ..but it is not working...tooltip only comes whenver I click on this dialog...
when i use dialog.show(); tooltip is working......but when i use setModal(true)...
it appear only when click on the dialog....i used dialog.exec() it is not working also...

why this is happening help me....

jpn
1st November 2007, 13:07
Does this work for you?


#include <QtGui>

int main(int argc,char* argv[])
{
QApplication app(argc, argv);
QDialog dialog;

QDialogButtonBox* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok, Qt::Horizontal, &dialog);
buttonBox->button(QDialogButtonBox::Ok)->setToolTip("Works!");

QVBoxLayout* layout = new QVBoxLayout(&dialog);
layout->addWidget(buttonBox);

return dialog.exec();
}

In case it does, could you modify the example so that it no more works?