QSystemTrayIcon hide() crash on mac while I use QTimer to change the icon of QSystemTrayIcon
-
sorry could you tell me detailedly how to format it ?
-
strange , when I edit it , the format looks well , but why when I post , it is so ugly .
-
[quote author="brucewuu" date="1309868142"]@//! [6]
void Window::messageClicked()
{
QMessageBox::information(0, tr("Systray"),
tr("Sorry, I already gave what help I could.n"
"Maybe you should try asking a human?"));
}//! [6]
void Window::createIconGroupBox()
{
iconGroupBox = new QGroupBox(tr("Tray Icon"));iconLabel = new QLabel("Icon:"); iconComboBox = new QComboBox; iconComboBox->addItem(QIcon(":/images/bad.svg"), tr("Bad")); iconComboBox->addItem(QIcon(":/images/heart.svg"), tr("Heart")); iconComboBox->addItem(QIcon(":/images/trash.svg"), tr("Trash")); showIconCheckBox = new QCheckBox(tr("Show icon")); showIconCheckBox->setChecked(true); QHBoxLayout *iconLayout = new QHBoxLayout; iconLayout->addWidget(iconLabel); iconLayout->addWidget(iconComboBox); iconLayout->addStretch(); iconLayout->addWidget(showIconCheckBox); iconGroupBox->setLayout(iconLayout);
}
void Window::createMessageGroupBox()
{
messageGroupBox = new QGroupBox(tr("Balloon Message"));typeLabel = new QLabel(tr("Type:")); typeComboBox = new QComboBox; typeComboBox->addItem(tr("None"), QSystemTrayIcon::NoIcon); typeComboBox->addItem(style()->standardIcon( QStyle::SP_MessageBoxInformation), tr("Information"), QSystemTrayIcon::Information); typeComboBox->addItem(style()->standardIcon( QStyle::SP_MessageBoxWarning), tr("Warning"), QSystemTrayIcon::Warning); typeComboBox->addItem(style()->standardIcon( QStyle::SP_MessageBoxCritical), tr("Critical"), QSystemTrayIcon::Critical); typeComboBox->setCurrentIndex(1); durationLabel = new QLabel(tr("Duration:")); durationSpinBox = new QSpinBox; durationSpinBox->setRange(5, 60); durationSpinBox->setSuffix(" s"); durationSpinBox->setValue(15); durationWarningLabel = new QLabel(tr("(some systems might ignore this " "hint)")); durationWarningLabel->setIndent(10); titleLabel = new QLabel(tr("Title:")); titleEdit = new QLineEdit(tr("Cannot connect to network")); bodyLabel = new QLabel(tr("Body:")); bodyEdit = new QTextEdit; bodyEdit->setPlainText(tr("Don't believe me. Honestly, I don't have a " "clue.nClick this balloon for details.")); showMessageButton = new QPushButton(tr("Show Message")); showMessageButton->setDefault(true); QGridLayout *messageLayout = new QGridLayout; messageLayout->addWidget(typeLabel, 0, 0); messageLayout->addWidget(typeComboBox, 0, 1, 1, 2); messageLayout->addWidget(durationLabel, 1, 0); messageLayout->addWidget(durationSpinBox, 1, 1); messageLayout->addWidget(durationWarningLabel, 1, 2, 1, 3); messageLayout->addWidget(titleLabel, 2, 0); messageLayout->addWidget(titleEdit, 2, 1, 1, 4); messageLayout->addWidget(bodyLabel, 3, 0); messageLayout->addWidget(bodyEdit, 3, 1, 2, 4); messageLayout->addWidget(showMessageButton, 5, 4); messageLayout->setColumnStretch(3, 1); messageLayout->setRowStretch(4, 1); messageGroupBox->setLayout(messageLayout);
}
void Window::createActions()
{
minimizeAction = new QAction(tr("Mi&nimize"), this);
connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide()));maximizeAction = new QAction(tr("Ma&ximize"), this); connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); restoreAction = new QAction(tr("&Restore"), this); connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); quitAction = new QAction(tr("&Quit"), this); connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit()));
}
void Window::createTrayIcon()
{
trayIconMenu = new QMenu(this);
trayIconMenu->addAction(minimizeAction);
trayIconMenu->addAction(maximizeAction);
trayIconMenu->addAction(restoreAction);
trayIconMenu->addSeparator();
trayIconMenu->addAction(quitAction);trayIcon = new QSystemTrayIcon(this); trayIcon->setContextMenu(trayIconMenu);
}
@
is this a qt bug ? or something I did wrong somewhere[/quote] -
If you start and end your code section in your post with an 'at' sign ('@') it will look much nicer. That is what the others are asking for.
I have just added in the post above these two signs in the begin at the end. And voila it looks much better.
Sorry, had to do two posts ;-)
-
there is a wiki page explaining how the editor works :
"Using the editor :":http://developer.qt.nokia.com/wiki/ForumHelp#9bd9c32b79efb1b2d5b039e4d48300a9 -
ok , guys , thanks very much , I have changed them now ~~anyone could give me solution ?thanks
-
It may be caused by some internal objects that are no longer available after you hide the icon. I can reproduce the crash on my Mac box.
As a workaround you can replace the call to hide with a single shot timer in your slot like this
@
fSystemTrayTimer->stop() ;
//fSystemTrayIcon->hide();
QTimer::singleShot(0, fSystemTrayIcon, SLOT(hide()));
@This way the call to hide is delivered after you have left the slot.
EDIT:
I've added this as a doc not to [[Doc:QSystemTrayIcon]] too. -
thanks Volker , you are always the best problem solver for me . Great Appreciation ~~~
-
hi Volker , I also meet the same problem as the following link
http://svn.netlabs.org/qt4/ticket/201
do you have some solution for that ?thanks ~~ -
I'll have a look into this later.
-
thanks very much , I have read the guide to ask questions , it is very helpful for me , thank you very much , I will do this better ~~
-
I didn't forget you but I was terribly busy the last week and am off for vacation soon, so please be a bit more patient.
-
thanks Volker ~~just have a look when you have time , thanks
-
[quote author="brucewuu" date="1309959197"]hi Volker , I also meet the same problem as the following link
http://svn.netlabs.org/qt4/ticket/201
do you have some solution for that ?thanks ~~[/quote]That's out of scope for me. I don't know the internal workings for the OS/2 port, sorry.