PDA

View Full Version : How to show a frameless dialog - DOESN'T WORK



franco.amato
6th April 2010, 16:26
Hi to all,
I would show a frameless dialog from my gui but I can't.
This is my code:


#ifndef __INFODLG_H__
#define __INFODLG_H__

#include "GeneratedFiles/ui_infoDlg.h"
#include <QDialog>

class MainWindow;

class InfoDlg : public QDialog
{

public:
InfoDlg( QWidget *parent );
virtual ~InfoDlg();

private slots:

protected:

private:
Ui::infoDlg ui;
MainWindow* win;
};

#endif __INFODLG_H__

and the *.cpp


#include "InfoDlg.h"

InfoDlg::InfoDlg( QWidget *parent )
: QDialog(parent)
{
ui.setupUi(this);
setWindowFlags( Qt::FramelessWindowHint );
win = (MainWindow*)parent;
}

InfoDlg::~InfoDlg()
{
}

here I create the dialog



void MainWindow::test()
{
InfoDlg dlg(this);
dlg.exec();
}

Unfortunately it doesn't work. I tried either with exec and show methods without success.

Where is the problem?

Regards

toutarrive
6th April 2010, 16:42
You've got an example of a frameless QDialog in Qt Demo. Have a look at widgets -> windows flags

vcp
6th April 2010, 18:00
Hi

I use this code and all works fine.



DlgAbout *d = new DlgAbout(0,0,"1.00.00"); // QDialog
d->setWindowTitle(tr("About"));
d->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
d->show();


Note: DlgAbout is a gui create with Qt4 Designer

franco.amato
7th April 2010, 00:53
Hi

I use this code and all works fine.



DlgAbout *d = new DlgAbout(0,0,"1.00.00"); // QDialog
d->setWindowTitle(tr("About"));
d->setWindowFlags(Qt::FramelessWindowHint | Qt::Dialog);
d->show();


Note: DlgAbout is a gui create with Qt4 Designer

It works thank you very much.
The problem was the Qt::Dialog missed.

Now I would do the dialog background transparent :-)

linste0815
2nd June 2010, 17:21
Hi,

I have a problem on SDK (OS:Windows Vista).
I also use setWindowFlags((this->windowFlags()|Qt::FramelessWindowHint) ,but it still have gray line around window.
Can somebody help ....?

note: you can see the picture in attachment.

linste0815