敬告遊客:
以下內容枯燥無聊,若情非得已不建議進入。
若仍執意進入,當有頭暈嘔吐現象時請盡速離開本篇文章。
menu.h
#include
#include
class menu : public QWidget
{
Q_OBJECT
public:
menu(QWidget *parent = 0);
private:
QAction *minimizeAction;
QAction *restoreAction;
QAction *quitAction;
QMenu *m_contextMenu;
void create_contextmenu();
}
menu.cpp
#include "tmenu.h"
#include
#include
#include
#include
menu::menu(QWidget *parent)
: QWidget(parent)
{
create_contextmenu();
}
void menu::create_contextmenu()
{
minimizeAction = new QAction(tr("Mi&nimize"), this);
connect(minimizeAction, SIGNAL(triggered()), this, SLOT(showMinimized()));
restoreAction = new QAction(tr("&Restore"), this);
connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal()));
quitAction = new QAction(tr("&Quit"), this);
connect(quitAction, SIGNAL(triggered()), this, SLOT(close_app()));
m_contextMenu = new QMenu(this);
m_contextMenu->addAction(minimizeAction);
m_contextMenu->addAction(restoreAction);
m_contextMenu->addSeparator();
m_contextMenu->addAction(quitAction);
}
bool menu::winEvent ( MSG * msg, long * result )
{
int msgType = msg->message;
if (msgType == 0x0313 )//(msgType == 787 )//787 only triggered in XP, 7 doesn't have this event.
{
qDebug() << "Show Context menu;
minimizeAction->setEnabled(!isMinimized());
restoreAction->setEnabled(true);
quitAction->setEnabled(true);
QPoint gpos = QCursor::pos();
m_contextMenu->move(gpos.x(), gpos.y() - m_contextMenu->height());
m_contextMenu->show();
}
return false;
}
Ref:
http://nicug.blogspot.com/search/label/taskbar
http://qtexperience.blogspot.com/2010/07/taskbar-context-menu-for-framless.html
公告版位
努力減肥.加油加油!
- Jun 03 Fri 2011 13:48
[Qt] customize jump list menu when right click in taskbar
close
文章標籤
全站熱搜
留言列表