PDA

View Full Version : QDialog - no title bar



Tomasz
22nd July 2010, 10:14
Hello!

I've wrote simple program that have main window and dialog window which can by open by clicking a button. Code of that dialog window looks like this:



#include <QGridLayout>
#include <QPushButton>
#include <QIcon>

#include "pomiary.h"

Pomiary::Pomiary(QWidget *parent)
: QDialog(parent)
{
setupUI();
}

void Pomiary::setupUI()
{
setModal(true);
setGeometry(QRect(50,0,100,150));
setWindowIcon(QIcon(":/images/icon.png"));

QGridLayout* PomiaryLayout = new QGridLayout;
setLayout(PomiaryLayout);

QPushButton *button = new QPushButton();
button->setIcon(QIcon(":/images/icon2.png"));
button->setIconSize(QSize(48, 48));
button->setFixedSize(60, 60);
PomiaryLayout->addWidget(button,0,0,Qt::AlignHCenter);

}


and when I open my application i don't have title bar on dialog window so I can't close it. I've tried to use setWindowFlags() but with no result. Only If I delete 'setGeometry()' window has title bar but is very small, and I want specific size. What I'm doing wrong?

thanks in advance
best regards
Tomasz

wysota
22nd July 2010, 11:14
What if you change "0" in your setGeometry call to say... 40?

Tomasz
22nd July 2010, 14:36
I've used setFixedSize(); and it worked perfectly.

best regards
Tomasz

wysota
22nd July 2010, 15:39
In general I think youi are missing a point of how Qt does its job. Setting fixed size on a dialog is a bad idea and having to do that often means you did something very wrong (like not using layouts).