-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a25dd54
commit 77169a7
Showing
14 changed files
with
531 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#include "mylabel.h" | ||
|
||
Widget::Widget(QWidget *parent) | ||
: QWidget(parent) | ||
{ | ||
QVBoxLayout *l=new QVBoxLayout(this); | ||
label= new QLabel(this); | ||
label->setContextMenuPolicy(Qt::CustomContextMenu); | ||
connect(label, SIGNAL(customContextMenuRequested(QPoint)), | ||
SLOT(customMenuRequested(QPoint))); | ||
l->addWidget(label); | ||
} | ||
|
||
Widget::~Widget(){} | ||
|
||
void Widget::customMenuRequested(QPoint pos){ | ||
//QModelIndex index=label->indexAt(pos); | ||
|
||
QMenu *menu=new QMenu(this); | ||
menu->addAction(new QAction("Action 1", this)); | ||
menu->addAction(new QAction("Action 2", this)); | ||
menu->addAction(new QAction("Action 3", this)); | ||
menu->popup(label->pos()); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef MYLABEL_H | ||
#define MYLABEL_H | ||
|
||
#include <QLabel> | ||
#include <QVBoxLayout> | ||
#include <QMenu> | ||
|
||
class Widget : public QWidget | ||
{ | ||
Q_OBJECT | ||
|
||
public: | ||
Widget(QWidget *parent = 0); | ||
~Widget(); | ||
|
||
public slots: | ||
void customMenuRequested(QPoint pos); | ||
|
||
private: | ||
QLabel *label; | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#------------------------------------------------- | ||
# | ||
# Project created by QtCreator 2015-01-11T16:13:41 | ||
# | ||
#------------------------------------------------- | ||
|
||
QT += core gui | ||
|
||
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets | ||
|
||
TARGET = hello | ||
TEMPLATE = app | ||
|
||
|
||
SOURCES += main.cpp\ | ||
mainwindow.cpp | ||
|
||
HEADERS += mainwindow.h | ||
|
||
FORMS += mainwindow.ui |
Oops, something went wrong.