I mean reinplementing mousePressEvent() that can give ignore right button pressed
I mean reinplementing mousePressEvent() that can give ignore right button pressed
a life without programming is like an empty bottle![]()
Reimplementing contextMenuEvent() is the right thing to do, not mousePressEvent().Originally Posted by zlatko
Save yourself some pain. Learn C++ before learning Qt.
Although I haven't tried this, and I am not at a comp w/ Qt installed right now and won't be for several hours, but as far as I understand the docs, you can also do the following:
1. Create all the actions you want in the menu.
2. Add these actions to the widget, using QWidget::addAction(...)
3. Set the widgets contextPolicy to Qt::ActionsContextMenu
If I understand correctly, this way, when your widget receives the context menu event, it will display its QWidget::actions() as context menu.
Bojan
The march of progress:
C:
printf("%10.2f", x);
C++:
cout << setw(10) << setprecision(2) << showpoint << x;
Java:
java.text.NumberFormat formatter = java.text.NumberFormat.getNumberInstance();
formatter.setMinimumFractionDigits(2);
formatter.setMaximumFractionDigits(2);
String s = formatter.format(x);
for (int i = s.length(); i < 10; i++) System.out.print(' ');
System.out.print(s);
Is the issue here about having a context menu for the whole widget or only for a part of it? Is that rectangle a widget on its own or is it just some hotspot not being a standalone widget itself? If the former, then all above mentioned methods apply, but if the latter, the issue is about checking whether the event is to be handled or ignored and you have to do it by checking coordinates of the event -- if they are within specified bounds, execute the menu (QMenu::exec), otherwise just do nothing.
What i'm actually trying out is that .....
When we minimise a window and then right click on it, we a shown with these options right("close","maximise","minimise","move","size", "restore")...... and even when we right click on the tiltle bar(in blue) when the window is open we are shown with these options...
These are given to us by the operating System ...
IN my application....
What i did was, I cut off the title bar( the thing in blue in every window we open with minimise,restore, and close options ) and implemented a widget which is a simple rectangle on top of my UI inteface of my application and I was trying to implement a defaultContextMenu on this and tried to see whether this could act as the context menu given to us by the operating system......
Is there any thing which could give us this and
And if it does not exists what could be the solution given to this.....
This is where I'm stuck .....Please give me the solution in detail.... including the code to do this ......![]()
@Naveen:This is where I'm stuck .....Please give me the solution in detail.... including the code to do this ......
All though you have the right to ask this, you should be aware that this is not very appreciated on forums such as this one.
People like to help, but you should show some effort to solve your own problems, therefore asking for the full solution is not liked, never the less, allowed.
It also doesn't help if you post double, and then when the double post was deleted post it again...
What exactly do you want to achieve? Maybe there are better ways to do this. But if you insist on doing it this way, just create that rectangle as a QFrame and either reimplement its contextMenuEvent directly if you code by hand or install an event filter on the frame to catch its events and handle them elsewhere. With Qt4 there is also an option to use custom context menu on the frame which gives an ability to use signals and slots for handling the menu.
Bookmarks