[Qt-interest] QDialog behavior

Tony Thompson Tony.Thompson at stone-ware.com
Thu May 7 05:06:18 CEST 2009


Well, I put together a sample app to demonstrate the issue I am having
and I have it down to a pretty simple app.  I can post my ui if needed.
I just created a plain dialog and I think I set the modal flags.  If I
remove the modal flags it doesn't make any difference.

main.cpp
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Dialog d;
d.show();
return a.exec();
}

dialog.cpp
Dialog::Dialog(QWidget *parent)
: QDialog( parent, Qt::Dialog | Qt::CustomizeWindowHint |
Qt::WindowTitleHint ), ui(new Ui::Dialog)
{
ui->setupUi(this);
setFixedSize( size() );
}

Dialog::~Dialog()
{
delete ui;
}

If I do setFixedSize( size() ), that totally screws up the window on
Linux.  This is how I get frameless dialog.  If I remove that, I get a
dialog with a title bar and system menu.  I am not asking for the system
menu so I am not sure why that is there either.

I would like the dialog set so it can't be resized.  Should I be doing
it differently?  setFixedSize() seems to do exactly that but it screws
up everything.

My other issue is still on the Mac with specifying those flags I get
grayed out buttons (close, min, max).

Any help with these issues appreciated.  Not sure if it something with
my Linux install (Ubuntu 9.04 Desktop) or (dare I ask?) a possible bug?

Thanks
Tony

On Tue, 2009-05-05 at 23:01 -0400, Tony Thompson wrote:
> After a bit more experimenting, I know why I added those flags on my
> dialog.  And it gets even more weird...
> 
> I would like a dialog with a plain title bar.  No window close buttons,
> no system menu, no "?" button on Windows.  I have an icon specified for
> my dialog so I only want the icon and the title of the dialog to show.
> 
> If I specify those flags:
> windows - no icon but plain title bar (no buttons) with title (pretty
> close)
> Linux - no title bar or window frame (my original issue)
> Mac - title bar with icon and title, grayed out system buttons (min, max
> close) (not bad)
> 
> If I don't specify those flags:
> windows - title bar with icon (and system menu), title, "?" what's this
> button, and close button
> Linux - title bar with icon (and system menu), title, close button
> Mac - title bar with icon and title (PERFECT!)
> 
> I can't seem to find a set of flags that will give me what I want on all
> platforms.  The only one that really works the way I want is on the Mac
> without the flags.  Is there some combination of window flags that will
> give me what I want on all platforms?  Or do I have to set flags in an
> OS specific way to get the dialog to behave on each platform?  Any hints
> on how I might set those flags even if it is OS specific?
> 
> I can provide screen shots for each of my cases if it would help but I
> didn't feel it beneficial to flood the list with them.
> 
> On Tue, 2009-05-05 at 22:28 -0400, Tony Thompson wrote:
> > Well, now I feel really stupid....in my search for how the parent was
> > set for my QDialog, I found that I was setting two window flags: 
> > 
> > Qt::CustomizeWindowHint | Qt::WindowTitleHint
> > 
> > Not sure I remember why I was doing that but when I removed them,
> > everything started working on Linux then.  It is odd that these flags
> > had no effect on the dialog behavior on Windows or OS X but made it
> > display differently on Linux.
> > 
> > My QDialog does not have a parent, BTW.  My application only has a
> > QSystemTrayIcon as its interface.
> > 
> > One other odd thing I have noticed about the dialog.  It is set as a
> > modal dialog which Linux seems to honor.  My system tray icon context
> > menu no longer works.  On Windows and Mac, it doesn't matter if the
> > dialog is modal or not, I can still use the context menu on the system
> > tray icon.
> > 
> > Nice that I start out with a Linux only issue and now the issue switches
> > to the other two platforms and Linux works fine.
> > 
> > On Wed, 2009-05-06 at 05:11 +0530, Raja Sekharan wrote:
> > > Could be that the parent of the dialog is not set properly. Or the
> > > parent is a widget like MDIArea? 
> > > 
> > > 
> > > I once set an MDIArea as a parent of a dialog box. When the dialog was
> > > 'exec'ed, I saw only the form elements on the dialog not the form or
> > > the title bar itself. It looked like the dialog's elements were on the
> > > MDIArea. Are you facing a similar problem? Could you elaborate/ give a
> > > screenshot?
> > > 
> > > 
> > > Rajasekharan
> > > _______________________________________________
> > > Qt-interest mailing list
> > > Qt-interest at trolltech.com
> > > http://lists.trolltech.com/mailman/listinfo/qt-interest
> >  
> > This message (and any associated files) is intended only for the 
> > use of the individual or entity to which it is addressed and may 
> > contain information that is confidential, subject to copyright or
> > constitutes a trade secret. If you are not the intended recipient 
> > you are hereby notified that any dissemination, copying or 
> > distribution of this message, or files associated with this message, 
> > is strictly prohibited. If you have received this message in error, 
> > please notify us immediately by replying to the message and deleting 
> > it from your computer. Messages sent to and from Stoneware, Inc.
> > may be monitored.
> > _______________________________________________
> > Qt-interest mailing list
> > Qt-interest at trolltech.com
> > http://lists.trolltech.com/mailman/listinfo/qt-interest
> _______________________________________________
> Qt-interest mailing list
> Qt-interest at trolltech.com
> http://lists.trolltech.com/mailman/listinfo/qt-interest



More information about the Qt-interest-old mailing list