I'm new in Qt World)
I created a new Qt Application in MSVC 2008
Using Qt Creator added controls I need and one of them is QMenuBar
As I understend the equivalent of CallBack(C#) is Slot in Qt.
I culdn't find any information how to create a custom Slot for QMenu using Qt Creator.
Asked
Active
Viewed 226 times
-1
-
Please use the tags for tagging your question, rather than flooding the title with them. – yoozer8 Aug 07 '12 at 17:47
1 Answers
1
- Subclass QMenuBar, and call the new class whatever you want, e.g.,
FancyMenuBar
. - Add the
Q_OBJECT
macro in your class definition (google for more info) in fancymenubar.h. - Add the line
public slots:
in your class definition, e.g., somewhere betweenpublic:
andprivate:
. - Add the slot definition under that line, e.g.,
void fancySlot();
. - Implement the slot definition, e.g.,
(in fancymenubar.cpp)
void FancyMenuBar::fancySlot()
{
// type code here
}
Now you can use the slot via the QObject::connect()
function, or use the slot as if it were a normal public function.

Anthony
- 8,570
- 3
- 38
- 46