Frameless QMainWindow resizing issue
-
Hi,
I'm writing an Qt 5 app on Ubuntu Linux 13.10 and I'm experiencing an issue with a Frameless QMainWindow. What appears to be happening is resize is taking into account for the border and title bar even though they are not there and wraps the background image. If I remove the Qt::FramelessWindowHint the image displays perfectly. I'm not sure if this is a bug or something I'm doing wrong.
@media::media(QWIdget *parent) : QMainWindow(parent, Qt::FramelessWindowHint)
{
loadImage();
}media::loadImage()
{
QImage *image;
QPalette p;image = new QImage("pathToFile"); p.setBrush(backgroundRole(), QBrush(*image)); setPalette(p); resize(image->width(), image->height(); show();
}@
This code worked perfectly in Qt 4 and works as designed in Qt5 as long as the Qt::FramelessWindowHint is not set. The image is a 800 x 600 jpeg. One other thing if I set the resize to 800 x 575 the image is perfect, the only thing I can think of is it's taking into account the size of the frame on its resize.
Thanks..
-
I tested the code on QT 5.2.0 64bit under fedora19 and I didn't see any problems
@
#include <QImage>
#include <QPalette>
#include <QDebug>MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent, Qt::FramelessWindowHint)
{
QImage *image;
QPalette p;image = new QImage("/home/seiko/Desktop/970583_529705863760005_1627626582_n.jpg"); p.setBrush(backgroundRole(), QBrush(*image)); setPalette(p); resize(image->width(), image->height()); show(); qDebug() << "photo size " << image->width() << image->height();
}
MainWindow::~MainWindow()
{}
void MainWindow::showEvent(QShowEvent *e){
qDebug() << "showEvent " << width() << height();QMainWindow::showEvent(e);
}
void MainWindow::resizeEvent(QResizeEvent *e){
qDebug() << "resizeEvent " << width() << height();QMainWindow::resizeEvent(e);
}
@
result wasresizeEvent 960 636
showEvent 960 636
photo size 960 636
resizeEvent 960 636 -
I've got 5.0.2 installed, I'll see about updating it and get back to you. Thanks for your help.
-
Update: I still haven't got Qt 5.2 installed yet however the problem seems to go away if I set the monitor screen to the size of the image. With that being said if my frameless mainwindow creates a QDialog it draws the taskbar across the top over the mainwindow and wraps the image within the QDialog, how would one execute a QDialog so that it won't draw the taskbar?