I'm trying to create an application for brightness control in Ubuntu 13.04. The idea is to make a tray icon and slider which appears as the icon is pressed. The problem is that the tray menu contains just an empty item. Here is the block of code, which works but not properly (it shows the slider only when the empty menu item is pressed):
cntrl::cntrl(QWidget *parent):
QWidget(parent)
{
value = 2500;
slider = new QSlider (Qt::Horizontal,this);
slider->setValue(2500);
slider -> setRange(0,maxBrightness);
slider -> setSingleStep(50);
slider->setPageStep(50);
tray = new QSystemTrayIcon (this);
menu = new QMenu (this);
act = new QWidgetAction (this);
act->setDefaultWidget(slider);
menu->addAction(act);
tray->setContextMenu(menu);
tray->setIcon(QIcon(":/brightness2.png"));
tray->show();
connect (slider,SIGNAL(valueChanged(int)),this,SLOT(changeBrightness(int)));
connect(act,SIGNAL(triggered()),menu,SLOT(show())); //trying to make it work somehow
}
What's wrong ?