I have a Qt application running on a windows XP machine and i am trying to finally disable the context menu which pops up when right clicking on a scroll bar (with the “scroll down” and “page up” etc. .. ) inside this application.
I tried the following things, which didn’t work:
ui->scrollArea->setContextMenuPolicy(Qt::NoContextMenu);
ui->scrollAreaWidgetContents->setContextMenuPolicy(Qt::NoContextMenu);
ui->scrollArea->horizontalScrollBar()->setContextMenuPolicy(Qt::NoContextMenu);
ui->scrollArea->setContextMenuPolicy(Qt::PreventContextMenu);
ui->scrollAreaWidgetContents->setContextMenuPolicy(Qt::PreventContextMenu);
ui->scrollArea->horizontalScrollBar()->setContextMenuPolicy(Qt::PreventContextMenu);
I never found out why it didn’t really worked in my context (it seems it has to do with nested widgets and objects) but I found a solution which is something like a sledge-hammer method but works for me:
This disables context menus of scrollbars (or other objects if modified) in the whole application once at startup.