Results 1 to 5 of 5

Thread: Qt::FramelessWindowHint resizing a widget

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jan 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Qt::FramelessWindowHint resizing a widget

    Qt Code:
    1. CustomWidget::CustomWidget( QWidget *parent )
    2. : QWidget( parent )
    3. {
    4. setWindowFlags( Qt::FramelessWindowHint );
    5. resize( 10, 50 );
    6. }
    7.  
    8. void CustomWidget::paintEvent( QPaintEvent *event )
    9. {
    10. QPainter painter( this );
    11. painter.setRenderHint( QPainter::Antialiasing, true );
    12. painter.setPen( Qt::black );
    13. painter.setBrush( QBrush( QPixmap( "images/blueblend.jpg" ) ) );
    14. painter.drawRoundedRect(0, 0, size().width(), size().height(), 5, 25, Qt::AbsoluteSize );
    15.  
    16. }
    To copy to clipboard, switch view to plain text mode 

    I was just messing around with trying to learn how to make a custom widget. With the code above, I get the following widget:
    http://img37.imageshack.us/img37/3286/framedj.jpg

    But with the frameless window hint I get:
    http://img204.imageshack.us/img204/6900/frameless.jpg


    What's the reason of it getting resized? Is there a way I can resize it back?
    Attached Images Attached Images
    Last edited by Plissken; 2nd July 2012 at 07:49.

  2. #2
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt::FramelessWindowHint resizing a widget

    The attachments are not working for me

  3. #3
    Join Date
    Jan 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt::FramelessWindowHint resizing a widget

    Fixed the links.

  4. #4
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Wiki edits
    17

    Default Re: Qt::FramelessWindowHint resizing a widget

    To be clear, the frameless version is the correct size, i.e. 10 pixels wide, 50 high. The framed version looks like a minimum width is being forced to accommodate the window controls. On my Linux machine a similar thing happens and the control gets sized to 18x50.

    Unless you intend that the 10x50 control appears in isolation on the desktop rather than part of a larger layout I cannot see the problem. What exactly is the problem you are trying to solve?

  5. #5
    Join Date
    Jan 2011
    Posts
    19
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Qt::FramelessWindowHint resizing a widget

    Ah, thanks Chris. I didn't think about minimum width being enforced for controls. The first time I ran it with the border so I thought that was 10x50.

Similar Threads

  1. Widget is not so smooth when resizing?
    By MorrisLiang in forum Newbie
    Replies: 2
    Last Post: 11th May 2010, 02:44
  2. QDock Widget resizing
    By vajindarladdad in forum Qt Programming
    Replies: 0
    Last Post: 9th December 2008, 11:12
  3. Resizing back the widget
    By gruszczy in forum Qt Programming
    Replies: 6
    Last Post: 23rd November 2008, 11:14
  4. Resizing child Widget
    By Pragya in forum Qt Programming
    Replies: 1
    Last Post: 30th March 2007, 07:58
  5. Widget resizing problem
    By fwohlfert in forum Qt Programming
    Replies: 3
    Last Post: 23rd February 2006, 09:16

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
  •  
Qt is a trademark of The Qt Company.