QWidgetAction in systemtray works in centos but unable to display in ubuntu
Unsolved
General and Desktop
-
Qt version: 5.6.1
OS version:- centos 6.3
- ubuntu 14.04
here is the code which run normal in centos but fails in ubuntu.
In ubuntu , the test action shows normally however the custom widget turn out to be a blank action.
why this happened?
#include <QApplication> #include <QDialog> #include <QBoxLayout> #include <QToolBar> #include <QStyle> #include <QWidgetAction> #include <QSpinBox> #include <QMenu> #include <QSystemTrayIcon> class MyWidgetAction : public QWidgetAction { public: MyWidgetAction(QObject *parent) : QWidgetAction(parent) {} virtual ~MyWidgetAction() {} protected: virtual QWidget *createWidget(QWidget *parent) { QSpinBox *sb = new QSpinBox(parent); sb->setToolTip("Spin"); return sb; } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); QMenu menu; menu.addAction(QString("test")); QWidgetAction *wa = new MyWidgetAction(&menu); menu.addAction(wa); tray.setContextMenu(&menu); tray.show(); return a.exec(); }
-
Hi! What desktop environment are you using on Ubuntu? Unity?