Results 1 to 11 of 11

Thread: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    2

    Question Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    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

  2. #2
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    2

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    Could anyone help with this? Any information will be appreciated!

  3. #3
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    What exactly are you having problems with?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  4. #4
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    2

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    Thanks for the reply!

    I'm not familiar with GUI development and I'm trying to write a skinnable window which is frameless but resizable by all its corners and edges. I'm looking for the typical/efficient way a sophisiticated GUI programmer would do.

  5. #5
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    You won't make progress by repeating what you have already said. Tell us what have you already tried, what problems have you stumbled upon, etc.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #6
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    2

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    Sorry if I didn't make my question clear. As I described in #1 of this post, I was able to ahieve my goal of resizing a frameless window. But since I'm not an experienced GUI programmer, I don't know whether those two approaches are the appropriate ones. It's not like I couldn't implement such functionalities, it's just that I highly doubt the two methods I came up with groundlessly were neither proper/efficient for such purposes.

    Thanks again for patiently helping me out!

    Regards


    Added after 6 minutes:


    In other words, I want to know whether the methods I came up with are appropriate or not. If not, then what is the proper method to make a frameless window resizable (not just adding one QSizeGrip, but resizable by all four corners and four edges).

    Thanks!
    Last edited by Sean; 25th October 2010 at 16:16.

  7. #7
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    I would probably implement a "charm" that could be applied on a widget consisting of an event filter that would intercept mouse-move events and modify the geometry of the widget. If I wanted to have cursor changes while moving along the borders of the window I would also enable mouse tracking for the widget as part of my charm. One can also check the code for controlling sub-windows of QMdiArea.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. The following user says thank you to wysota for this useful post:

    Sean (25th October 2010)

  9. #8
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    2

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    Thanks for your opinion! I care a lot about how much computational resource my algorithm consumes and that's why I posted this thread in the first place. If I keep tracking the mouse inside the window and calculating the corresponding geometry, will that be too much computation for such a simple task? Since the code we write through regular C++/QT statements are user-level code, and there are machine/OS dependent instructions/APIs which utilize hardware acceleration for such purposes. And QT use lots of them internally to improve its efficiency, just like video game developers regularly utilize video card facilities.

  10. #9
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    Hardware acceleration or anything like it will not help you determine whether you are at a window border or not. If you want to have such information inside your application, you need mouse tracking. The only alternative is to rely on the windowing system by not applying a custom skin and using the default decorations instead.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  11. #10
    Join Date
    Oct 2010
    Posts
    37
    Thanks
    3
    Thanked 1 Time in 1 Post
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    Quote Originally Posted by Sean View Post
    just like video game developers regularly utilize video card facilities.
    This is not the case. Engine developers do that and game developers use the engine. In the same way that gui library programmers handle the gritty details and application programmers use the library. Game programming is a large part scripting and setting up events. There's not much 3D programming done apart from writing the odd shader or maybe using a fragment program to speed a physics calculation (in extreme cases).

    I can't pretend to know your situation here, but if you're using Qt then likely you're not resource stricken- why are you rolling your own gui?

  12. The following user says thank you to genjix for this useful post:

    Sean (26th October 2010)

  13. #11
    Join Date
    Oct 2010
    Posts
    6
    Thanks
    2

    Default Re: Looking For Most Appropriate/Efficient Way Of Resizing A Frameless Window

    You are right. I'll track the mouse by myself to implement the resizing code.

    Quote Originally Posted by genjix View Post
    This is not the case. Engine developers do that and game developers use the engine. In the same way that gui library programmers handle the gritty details and application programmers use the library. Game programming is a large part scripting and setting up events. There's not much 3D programming done apart from writing the odd shader or maybe using a fragment program to speed a physics calculation (in extreme cases).

    I can't pretend to know your situation here, but if you're using Qt then likely you're not resource stricken- why are you rolling your own gui?
    Thanks for your advice! I'm gonna rely on what QT provides.

Similar Threads

  1. Resize handling of frameless window
    By Peppy in forum Qt Programming
    Replies: 5
    Last Post: 2nd June 2010, 21:48
  2. Replies: 0
    Last Post: 14th April 2010, 23:26
  3. Replies: 3
    Last Post: 2nd March 2010, 21:58
  4. KWin's shadows and frameless window
    By EuroElessar in forum KDE Forum
    Replies: 4
    Last Post: 12th July 2009, 17:16
  5. [QT4] Any way to disable window resizing ?
    By Amalsek in forum Qt Programming
    Replies: 5
    Last Post: 15th May 2006, 12:36

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.