Monday, 15 July 2013

c++ - Qt 5.3 QSystemTrayIcon not working correctly[Linux] -



c++ - Qt 5.3 QSystemTrayIcon not working correctly[Linux] -

so wrote qt5 application , wanted add together scheme tray icon qsystemtrayicon. after beingness done coding compiled , ran , scheme tray icon did not appear, tested around, added line display info bubble, did, in top left corner, instead of in scheme tray.

anyway tried qt4.8, compiled same code , there worked fine.

i'm using arch linux latest updates, xfce4 de , qt 5.3.0-3. made application qt creator.

i wrote illustration application has same behaviour. here's code:

mainwindow.h

#ifndef mainwindow_h #define mainwindow_h #include <qmainwindow> #include <qsystemtrayicon> #include <qicon> #include <qmenu> namespace ui { class mainwindow; } class mainwindow : public qmainwindow { q_object qsystemtrayicon *trayicon; qmenu *traymenu; public: explicit mainwindow(qwidget *parent = 0); ~mainwindow(); private slots: void on_pushbutton_clicked(); private: ui::mainwindow *ui; }; #endif // mainwindow_h

mainwindow.cpp

#include "mainwindow.h" #include "ui_mainwindow.h" mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent), ui(new ui::mainwindow) { ui->setupui(this); traymenu = new qmenu(this); traymenu->addaction("test"); trayicon = new qsystemtrayicon(this); trayicon->seticon(qicon(":/ui_conf.png")); trayicon->setcontextmenu(traymenu); trayicon->show(); trayicon->showmessage("well...", "here should guess?"); ui->pushbutton->seticon(qicon(":/ui_conf.png")); } mainwindow::~mainwindow() { delete ui; } void mainwindow::on_pushbutton_clicked() { this->close(); }

main.cpp

#include "mainwindow.h" #include <qapplication> int main(int argc, char *argv[]) { qapplication a(argc, argv); mainwindow w; w.show(); homecoming a.exec(); }

thanks in advance!

it's regression (bug) on qt 5.x versions. here bug record https://bugreports.qt-project.org/browse/qtbug-31762 it's still open :(

you can seek gtk code in qt app create working scheme tray icon/menu.

c++ linux qt

No comments:

Post a Comment