Hey guys!

I'm an experienced robotics system developer but rarely write any GUI programs.

I want to write a frameless window with all four sides(borders) and corners resizable, a.k.a top&bottom borders for vertical resizing with mouse cursor "Qt::SizeVerCursor", left&right borders for horizontal resizing with mouse cursor "Qt::SizeHorCursor", and corners for diagonal resizing with mouse cursor "Qt::SizeDiaCursor" just like some skinnable desktop applications.

For this purpose, I have two ideas in mind. One is rewrite the corresponding mouse events and calculate the geometric relationships of the mouse and the window to make it work. The other is to put eight QSizeGrip widgets onto four sides and four corners.

For idea one, I've checked out the implementation code of QSizeGrip and got the idea of what QT guys do. Since they use macros to write difference code for different OSes, if I directly borrow the code then I'm not utilizing the power of portability provided by QT. Therefore, I believe there should be some more portable and/or appropriate way of doing it with available QT infrastructures.

For idea two, I simply couldn't believe that's the right way to achieve my goal.

To be more specific, I'm looking for the "RIGHT" solution from sophisticated GUI programmers for doing this. 'cause I think there must be some de facto widely used routine for this commonly seen task.



For your reference, the characteristics of my window is briefly described as follows.

I inherited the QMainWindow and set the corresponding attributes like the following to make a frameless window.

...
Qt::WindowFlags flags = Qt::Window | Qt::FramelessWindowHint;
setWindowFlags(flags);
setAttribute(Qt::WA_TranslucentBackground);
After that, I use stylesheets to make the window stylish with round corners with Q Style Sheet language similar to the following.

QMainWindow > .QWidget {
border-style: dashed;
border-with: 3px;
border-radius: 6px;
...
}

Thanks in advance!

Regards,
Sean