PDA

View Full Version : Cursor is not changed when mouse is moving around the edges of a framed dockwidget



harregui
16th May 2011, 11:47
Hi everyone,

I've created a custom dockwidget with its custom titlebar. I've added a QFrame around the dockwidget and now, when the mouse is moving around the edges of the dockwidget, the cursor does not change to the sizehorcursor/sizevercursor shape.

Any ideas?

Thank you.

wysota
17th May 2011, 00:32
My idea is you messed up something in your code.

harregui
21st June 2011, 11:46
Hello again,

I must have messed up the whole code completely by now...

I'm still stuck with this issue. The thing is I don't know which widget/object/whatever is responsible for handling the cursor change when the mouse moves over the edges of a floating QDockwidget. Is this managed by the OS? (I hope not...)

When I hide the QFrame, everything seems to work fine, but when it is shown, something gets lost.
I want to give to my custom QDockWidget the appearance that a StyledPanel QFrame gives. Is there any other way to give that appearance getting rid of the QFrame? I couldn't add a "border" to the QDockWidget using stylesheets.

Thank you.

harregui
22nd June 2011, 09:52
Resizing works. The problem is that the cursor doesn't change if the QFrame is shown.

wysota
22nd June 2011, 10:35
Please prepare a minimal compilable example reproducing the problem.

harregui
5th July 2011, 08:05
Hi wysota, and thank you.
I hope the following code helps to understand my problem. The area of the "dock" that is not covered by the "frame" works fine (shows the resizing arrows).



ResizeArrowTest::ResizeArrowTest(QWidget *parent, Qt::WFlags flags)
: QMainWindow(parent, flags)
{
ui.setupUi(this);

QDockWidget *dock = new QDockWidget(this);
QWidget *titlebar = new QWidget();
dock->setTitleBarWidget(titlebar);
titlebar->show();
dock->setAutoFillBackground(false);
this->addDockWidget(Qt::LeftDockWidgetArea, dock);
dock->setFloating(true);
dock->setFeatures(QDockWidget::DockWidgetMovable);
QFrame *frame = new QFrame(dock);
frame->setFrameShape(QFrame::Shape::StyledPanel);
frame->show();

}

wysota
5th July 2011, 08:57
Please make your example compilable and minimal.

harregui
5th July 2011, 09:23
Sorry!
I hope it is "minimal" and "compilable" now...


#include <QtGui>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QMainWindow w;

QDockWidget *dock = new QDockWidget();
QWidget *titlebar = new QWidget();
dock->setTitleBarWidget(titlebar);
w.addDockWidget(Qt::LeftDockWidgetArea, dock);
dock->setFloating(true);
QFrame *frame = new QFrame(dock);
frame->setFrameShape(QFrame::Shape::StyledPanel);
frame->show();
w.show();

return a.exec();
}

wysota
5th July 2011, 15:56
Why would you expect the above code to change the cursor shape?

harregui
5th July 2011, 21:40
As far as I understand, if I remove (or hide) the QFrame, it works as I want to.
Then, if I add the QFrame, resizing the dockwidget with the mouse still works, so why shouldn't the cursor change the shape if resizing is available?

My guess is: QFrame is handling some sort of event when the mouse is moving over the edges, and that event is missed by the object in charge of the cursor shaping. But which one is the event? Who is in charge of the cursor shaping? (the application, the OS, the dockwidget,...?)

Otherwise should I reimplement the shaping myself? How could I determine if I should use horizontal or vertical arrows?

Or probably the cursor shaping is handled by the OS. In that case I find myself a little bit (more) lost...

Am I pointing to some kind of wrong direction? Thanks a lot for your time.

harregui
11th July 2011, 09:06
I also tried using stylesheets to add a border instead of the QFrame but I couldn't get any success.
I think using QFrame should do the job, but I must be missing something.