QT: Using the mouse wheel when dragging from outside of application - c++

I have a QT application with a TreeView in which items can be dragged into and around the TreeView. The Scroll wheel is able to scroll up and down the view when collapsed sufficiently to show the scroll bar in all cases except for when dragging in an item from the desktop.
Could anyone point me in the right directon? Or inform me on what questions I should be asking?

is the problem maybe related to the application not beeing in focus anymore? Keypresses (also mousewheel scroll) is usually send to the application which is activ/in focus.
I have done an private project which would react to keypresses on OS (windows) level to be able to control it while the user would play a computer game.
I don't have enough reputation to make a comment. Hope this might help you.

Related

Global mouse right button menu with movements for windows

I want to create something like plugin or driver for mouse and extend right button mouse menu with movements. First of all, I want to create next feature:
1.user press right button and while button pressed move mouse up
2.will be shown a simple image with the scheme. arrow up and text "close"
3.when button released current window will be closed.
something similar was in old opera browser and it was very comfortable.
I try to find in googleб but I found how to do only for WPF or browser. I want to create global for the whole system with different configs. for example mouse, up in explorer will close the window and in visual studio, it will fire "Run"(f5).
I want to create this using C#. also I have basic knowledge in c++.
I will be grateful for help

Keyboard focus: looking for a general strategy

My application has a big graphics area with some controls (sliders, buttons, text edit controls) in a side panel. The graphics area understands some keyboard commands.
My problem is that when a control in the side panel is in focus, the main graphics area won't receive any keyboard commands, so this confuses the users. However, for some controls, this is intended, e.g. text edit controls.
What I want is the focus to automatically return to the graphics area at the earliest possible occasion (which I call "greedy" focus) -- e.g. when text editing is finished (Enter key), or when the user has selected an item from a combo box.
I am looking for a clean and robust strategy for dealing with the problem, either using Windows API or Borland Vcl.
I'd appreciate if you want to share your ideas.
I haven't fully solved the problem yet, but a very useful message to intercept on form level is CM_DIALOGKEY (Borland Vcl only). It gets sent for every key that is normally used for navigating within the UI. That is, cursor keys, tab and shift-tab, Enter and possibly others.
I've added an event handler for CM_DIALOGKEY that returns the focus to the graphics area and also forwards the key press to that component. This way the user can still control the UI elements via keyboard (important for text entry), but cursor keys are handled by the graphics area.
I know what you mean I had similar problem with some BIG apps lice CAD/CAM ...
My solution is simple, robust and I use it for years.
1.all keystrokes handling for that gfx area
must be done in events of the Form where the area is located
not in panels,paint box whatever...
2.create unfocus function (preferably member of form but it is not required)
this function will loose focus of any VCL item
so the focus goes to form itself which is what you want
I am using this:
//---------------------------------------------------------------------------
void main_unfocus()
{
Main->bt_unfocus->Visible=true;
Main->bt_unfocus->SetFocus();
Main->bt_unfocus->Visible=false;
}
//---------------------------------------------------------------------------
Main is the Form pointer
bt_unfocus is button (can be any focusable VCL component)
I place this button usually on the left upper corner of App and set its size to 2x2 pixels
it is invisible at start
the idea is to set focus to it (but first unhide it so no exception is thrown)
and then hide it so it loses focus
work well in BCB5 and BDS2006 (did not used it with any other IDE)
as you can see most of the time is this component invisible
4.now when to call main_unfocus ?
when you go with mouse from outside to inside of your gfx area (OnMouseMove event)
or when you click on it
also you can combine this with remembering if the focus is or not in gfx area
that can be done with events like OnExit ...
or when you hit Esc while focus is inside edit box ...\
I am sure you grasp the idea and adjust this to your needs
Hope it helps

Constraining other application's window sizes through Qt Application

I'm looking for a way in Qt to constrain other application window's (some will not be Qt) so that when maximized don't overlap my Qt application. Essentially I want to create the Windows Taskbar. I'd like the applications edge to dock to the appropriate edge of my Qt Taskbar in the same way that applications dock to the Windows taskbar when they are maximized. I envision this taskbar to exist along the top edge of the screen, but would like to allow users to decide which edge it will live on.
I know it isn't hard to make a window that is always on top it's more the auto docking issue I'm having a hard time figuring out.
I'm right now only looking to accomplish this on Windows.
Thank for any help.
Detailed explanation on how to do it would be too long for an answer here, but MSDN documentation on SHAppBarMessage should get you started. Taskbar created like that can even be part of winows taskbar ;)

Qt Tray Icon Drag and Drop

Does anyone know if it is possible to use drag and drop with a tray icon using Qt?
I've been doing some research and here is what I have come up with:
A QSystemTrayIcon cannot explicitly handle a drag/drop event. However there is a workaround based on the Spifftastic tray icon location method.
You create a uniquely colored icon
and place it as the icon for a brief
moment and take a screenshot of it.
Given that you know the color
sequence for the icon, you can
search through the screenshot and
locate the particular icon's
location.
A transparent widget is positioned
over the icon and is used as the
drop target.
I have yet to work at a few of the finer details of the operation but that is the gist of it. All things considered it is a hacky way of things but given that there are no other ways to do this I think it is acceptable.
Fluffy App (written in C#) uses the Spifftastic method to locate the tray icon. I'm assuming the part about the transparent window is how they accomplish that but I have yet to decompile and examine their system.
Since QSystemTrayIcon is a QObject, not a QWidget, my guess is this is not possible. The system tray icon isn't really owned by Qt - it's passed on to the 'desktop', i.e whatever part of the Gnome/KDE/Windows/Mac is drawing the relevant area. At least on Mac, you'd be dropping on the menu-bar, which would be a very strange UI. For Gnome and KDE it's a FreeDesktop.org standard, but again I don't think its your process which actually does the drawing, and hence there's no way for Qt to get events such as drag and drop to you.

Qt Custom Window

Pardon me, I am a newbie :)
Is it possible in Qt to create a custom window without borders but still draggable without holding down the Alt Key? I created a borderless window but in order to be able to drag it (on Linux) you have to hold down the alt key.
I was planning to create a window with rounded corners. Any one have any idea how to make this possible? Although, I think implementing the mouseMove, mousePress or something is a possible solution but I need some other solution.
Thanks
There is just one way to make the window manager move the window: Add a drag bar. If there is no drag bar, then your app must move the window itself by setting the new position (i.e. you must handle the mouse click+move events yourself).
The feature to move the window by pressing Alt is also a function of your window manager, not Qt.
Yes, there is a rounded window example somewhere using a clock which does this. Basically, you need to manage the mouse clicks yourself as Aaron says.
You may use QDecoration (for Embedded Linux) to make it: here is the example.
Detect that the mouse is held down on your window, then grab the events for the mouse moving around so you can move your window in sync with it. When user releases mouse button your task is over.