Ich möchte ein Popup Menu öffnen, welches bei einer Auswahl ein Signal verschickt.
hier der Code snippet
Code: Alles auswählen
============================================
void ImageBox::mousePressEvent(QMouseEvent *e)
{
//MainWindow must adjust selection...
//Create menu
//Execute menu at current mouse position
if (e->button() == Qt::LeftButton){
mpMenu = new QMenu("menu", this);
p_Connect_action_1 = new QAction("Sentry01",this);
p_Connect_action_2= new QAction("Sentry03",this);
p_Connect_action_3= new QAction("Sentry04",this);
connect(p_Connect_action_1, SIGNAL(triggered()), this, SLOT(Connect("Sentry01")));
connect(p_Connect_action_2, SIGNAL(triggered()), this, SLOT(Connect("Sentry03")));
connect(p_Connect_action_3, SIGNAL(triggered()), this, SLOT(Connect("Sentry04")));
mpMenu->addAction(p_Connect_action_1);
mpMenu->addAction(p_Connect_action_2);
mpMenu->addAction(p_Connect_action_3);
mpMenu ->exec(QCursor::pos());
delete mpMenu ;
gParent->repaint();
}
emit Clicked(mX,mY);
}
void ImageBox::Connect(char* serverName)
{
//Hardcoded for Testing
strcpy(mServerName,serverName);
strcpy(mServerPort,"14334");
if (receiver.isRunning())
receiver.terminate();
receiver.wait();
receiver.setServer(mServerName, mServerPort);
//emit doConnect(mServerName, mServerPort);
receiver.start();
mpBox->hide();
update();
mpBox->show();
AdjustSize();
}
====================================
[/b]