QT在运行时更改QSystemTrayIcon

时间:2014-07-03 07:02:10

标签: qt

我试图在我的应用中的各个点更改QSystemTrayIcon,例如:

void MainWindow::goOnline() {

    isOnlineFlag = true;

    QIcon xmediaIcon("://notificationLogo.png");
    sti->setIcon(xmediaIcon);
}

void MainWindow::goOffline(bool manual) {

    isOnlineFlag = false;

    QIcon xmediaIcon("://notificationLogoOffline.png");
    sti->setIcon(xmediaIcon);
}

但由于某种原因,应用程序有时会崩溃。

崩溃日志:

Thread 0 Crashed:: Dispatch queue: com.apple.main-thread
0   QtGui                           0x0000000101813171 QIcon::operator=(QIcon const&) + 33
1   QtWidgets                       0x000000010207a2d6 QSystemTrayIcon::setIcon(QIcon const&) + 22
2   com.yourcompany.app             0x000000010002b089 MainWindow::goOffline(bool) + 617
3   com.yourcompany.app             0x00000001000bb736 MainWindow::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) + 19382
4   QtCore                          0x00000001013edda6 QMetaObject::activate(QObject*, int, int, void**) + 2550
5   QtCore                          0x00000001013e6c93 QObject::event(QEvent*) + 51
6   QtWidgets                       0x0000000101d55f2c QApplicationPrivate::notify_helper(QObject*, QEvent*) + 300
7   QtWidgets                       0x0000000101d58a1d QApplication::notify(QObject*, QEvent*) + 6157
8   QtCore                          0x00000001013bd0b2 QCoreApplication::notifyInternal(QObject*, QEvent*) + 114
9   QtCore                          0x000000010140e746 QTimerInfoList::activateTimers() + 982
10  libqcocoa.dylib                 0x0000000104e58fc5 QCocoaEventDispatcherPrivate::activateTimersSourceCallback(void*) + 21
11  com.apple.CoreFoundation        0x00007fff9038c731 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
12  com.apple.CoreFoundation        0x00007fff9037dea2 __CFRunLoopDoSources0 + 242
13  com.apple.CoreFoundation        0x00007fff9037d62f __CFRunLoopRun + 831
14  com.apple.CoreFoundation        0x00007fff9037d0b5 CFRunLoopRunSpecific + 309
15  com.apple.HIToolbox             0x00007fff86261a0d RunCurrentEventLoopInMode + 226
16  com.apple.HIToolbox             0x00007fff862617b7 ReceiveNextEventCommon + 479
17  com.apple.HIToolbox             0x00007fff862615bc _BlockUntilNextEventMatchingListInModeWithFilter + 65
18  com.apple.AppKit                0x00007fff837193de _DPSNextEvent + 1434
19  com.apple.AppKit                0x00007fff83718a2b -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 122
20  com.apple.AppKit                0x00007fff8370cb2c -[NSApplication run] + 553
21  libqcocoa.dylib                 0x0000000104e59d44 QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2404
22  QtCore                          0x00000001013ba64d QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 397
23  QtCore                          0x00000001013bd652 QCoreApplication::exec() + 354
24  com.yourcompany.app             0x0000000100007906 main + 1558
25  com.yourcompany.app             0x0000000100006584 start + 52

任何想法可能是什么问题?

0 个答案:

没有答案