Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWidgetAction in systemtray works in centos but unable to display in ubuntu
QtWS25 Last Chance

QWidgetAction in systemtray works in centos but unable to display in ubuntu

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 2 Posters 583 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    yveszhang
    wrote on last edited by
    #1

    Qt version: 5.6.1
    OS version:

    1. centos 6.3
    2. 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();
    }
    
    
    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      Hi! What desktop environment are you using on Ubuntu? Unity?

      1 Reply Last reply
      1
      • Y Offline
        Y Offline
        yveszhang
        wrote on last edited by
        #3

        the desktop environment is unity

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved