wxWidgets cursor over panel border - c++

I've got a variety of wxPanels contained in a main wxPanel which is in turn contained in a wxFrame.
I'm trying to set a custom cursor over all the children by calling SetCursor on the wxFrame that contains everything and it mostly works except when the mouse is over the children's border.
When the mouse is over a border, it reverts to the arrow.
Each border is set to wxBORDER_RAISED.
How do I make sure that my cursor is the same over a panel's borders as it is over the panel itself?
Here's how I set the cursor:
In my wxFrame
wxCursor wMyCursor(wCursorFilename, wxBITMAP_TYPE_CUR);
SetCursor(wMyCursor);
//tried this as well
wMainPanel->SetCursor(wMyCursor);
An other way of putting it might be "how do I set a custom cursor when the mouse is over a panel's border"?
cheers

Related

How to change the position of a window scrollbar?

How to change the position of the Vertical Scrollbar of a window?
I'm referring to the position in xy, for example set it in the middle of the window instead of the edges.
You cannot reposition a scrollbar that is built-in to a window. You will have to disable the native scrollbar (remove the window's WS_HSCROLL/WS_VSCROLL style) and then create a separate ScrollBar control as a child of the window. Then you can position that child wherever you want, using the x/y parameters of CreateWindow/Ex() or SetWindowPos().

Is there a way to attach or anchor two QWidgets together?

I'm getting started with Qt and decided to build a full-screen text editor. I want to have a button (button with arrow in screenshot) attached to a QDockWidget which opens and closes it so the button is always visible to the right side of the screen and stay anchored to it when dock is visible or resized.
My current app is a simple fullscreen textEdit set to centeralwidget in Mainwindow.
I haven't found a way to do this yet with layouts or existing addAnchor() functions so any help or direction is appreciated.
You can achieve what you want by using a container for your text edit and the button. A QWidget instance can be used as an "invisible"*** container for other widgets.
So in Qt Designer you add a widget as a central widget of the main-window, inside this widget you add the text edit and the button, then you set a vertical layout for this container widget.
Don't forget to restrict the docking widget to only dock to the right side, you can do that with: dock->setAllowedAreas(Qt::DockWidgetArea::RightDockWidgetArea); //assuming dock is the pointer to your QDockWidget.
In case you want the dockWidget to be able to dock to any side and the button to follow, you can do that too, but it get a little bit more complicated. Basically you need to connect a slot to dockLocationChanged of your dockWidget and based on where it's docked you need to set-up a new layout for the container widget to be vertical or horizontal and the order of the textEdit and the button based on the side the dock happened.
LE:*** you will most likely need to set the margins you want, since both the widget and it's layout can have them and the actual content might have higher spacing than you want.

QT, advance GUI, fancy context menu

i am working on a Qt project and i want to make a fancy context pie right click.... menu.
like the one in the image
bellow
I am using QGraphicsItem, QGraphicsScene, QGraphicsView, and setting the background transparent by
setAttribute(Qt::WA_TranslucentBackground);
setStyleSheet("background: transparent ;border: none;");
what i want to achieve is when user hove over the circle and it is a sub-menu then a pie menu will appears but,
The problem is:
sadly mouse events will not emit unless its touching a solid pixel from my QGraphicsView, so when mouse cursor hove over a sub-menu the red pie will appear BUT as soon as i move to click on a sector from the pie it will disappear because i am no longer hovering over the orange circle.
any another good idea or solution so i can get mouse events over my transparent area (i will calculate the distance from the orange circle and if the mouse IN RANGE the pie will stay shown)
thanks.
I think you can do this :
Hover the orange one and the sub menu appear.
Keep the sub menu appear until your mouse hover nothing or hover another circle menu. When you move your mouse to sub menu -> it means you hover thing, so the sub menu will still there. If your sub menus are all same, so when you hover another circle, just move sub menu position and maybe set some property.
Make sure that your orange circle and the sub menu is overlap, so moving mouse from orange to sub menu will not trigger "hover nothing"

QT : leaveEvent - Checking if the cursor is in region of a widget?

I currently have a class that inherits from QLabel this class implements the methods mouseMoveEvent and leaveEvent. When the mouse is over this widget a dialog box is displayed. However the dialog box only disappears if a mouse click occurs elsewhere. I want the dialog box to disappear when the mouse moves out of the reqion of this widget. I therefore thought about using the leaveEvent method which would call dialog.hide(). My question is how can I determine if the mouse cursor is in the region of a widget ?
Have a look at Qt - Determine absolute widget and cursor position. Two ways are explained there.. using coordinates and using QWidget::underMouse().

MFC Unclickable Button (Running away from cursor on MouseMove)

How would i make a button that will change it's position on MouseMove Event if the cursor is close enough to the center of the button in MFC ?
WM_MOUSEMOVE is not delivered to the button if the cursor is not over it (and is not captured, but you don't want that). So you have to process WM_MOUSEMOVE in the parent dialog. If you want your button to be a self-contained control, you have to subclass the parent window upon button creation.
Subclassing, in this context, means:
- you retrieve and store the parent's window proc address with GetParent()->GetWindowLong(GWL_WNDPROC)
- you set it to your procedure with SetWindowLong()
- in the procedure, you call the parent's previous window proc, after handling WM_MOUSEMOVE the way you want.
The WM_MOUSEMOVE coordinates will be relative to the screen, but you'll probably want to track the button position relative to the window that contains it. Use the ScreenToClient method on the parent window to convert, then you can compare the coordinates to see if it's close. Then use MoveWindow to move the button.
If you track the mouse cursor position you can determine when the cursor gets close to or enters the button window rect. You can then use the SetWindowPos() function to reposition the button window in the parent window client area.