Plissken
2nd July 2012, 06:06
CustomWidget::CustomWidget( QWidget *parent )
: QWidget( parent )
{
setWindowFlags( Qt::FramelessWindowHint );
resize( 10, 50 );
}
void CustomWidget::paintEvent( QPaintEvent *event )
{
QPainter painter( this );
painter.setRenderHint( QPainter::Antialiasing, true );
painter.setPen( Qt::black );
painter.setBrush( QBrush( QPixmap( "images/blueblend.jpg" ) ) );
painter.drawRoundedRect(0, 0, size().width(), size().height(), 5, 25, Qt::AbsoluteSize );
}
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?
: QWidget( parent )
{
setWindowFlags( Qt::FramelessWindowHint );
resize( 10, 50 );
}
void CustomWidget::paintEvent( QPaintEvent *event )
{
QPainter painter( this );
painter.setRenderHint( QPainter::Antialiasing, true );
painter.setPen( Qt::black );
painter.setBrush( QBrush( QPixmap( "images/blueblend.jpg" ) ) );
painter.drawRoundedRect(0, 0, size().width(), size().height(), 5, 25, Qt::AbsoluteSize );
}
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?