On 04/17/2014 08:57 PM, Murphy, Sean wrote:

Since there’s no reason to show that contextual menu on the ‘+’ tab, I’d like to disable the right click functionality just on the last tab, which I’m trying to do in the mousePressEvent for loop, by only looping to bar->count() – 1.  But the problem I’m having is that right-clicking on the ‘+’ tab emits currentChanged(int) BEFORE mousePressEvent() is called, so a new tab is being created in slotTabBarClicked(), so before the user right clicks, count() is 2, current index is 0, and the ‘+’ is on index 1.  Once the user right clicks on the ‘+’ tab, by the time we get to mousePressEvent(), count() is 3, current index is 1, and the ‘+’ tab is at index 2. So the mapping doesn’t work and I end up displaying a contextual menu on the newly created “Tab 2”, even though the user right-clicked on the ‘+’ tab.

 

The behavior I want is right-clicking on the ‘+’ should do nothing; it shouldn’t add a new tab, it shouldn’t show a contextual menu.

 

What am I missing?  Or how should I be trying to do this?  If there was a separate signal for left vs. right clicks, it’d be easy.  But I don’t see a way to easily detect in slotTabBarClicked(int) that it was a right-click that caused currentChanged(int) to be emitted…


How about avoiding currentChanged() and creating new tab in mousePressEvent() if its the left mouse button?


Syam



_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to