Do not use QWidget::showFullScreen() etc. (was Re: KDE)

Allen Winter winter at kde.org
Thu Mar 13 12:59:29 GMT 2008


On Thursday 13 March 2008 04:14:55 Matthias Kretz wrote:
> On Tuesday 11 March 2008, Lubos Lunak wrote:
> > > Remove usage of QWidget::show[FullScreen|Maximized|Minimized|Normal](),
> > > they do more then just change the state of the window and all these
> > > usage cases were wrong (that is, all their usage).
> > > For changing the state, use something like
> > > window->setWindowState( window->windowState() | Qt::WindowFullScreen );
> > > // set
> > > window->setWindowState( window->windowState() & ~Qt::WindowFullScreen
> > > ); // reset
> > > or simply use the new KToggleFullScreenAction::setFullScreen()  helper.
> >
> >  People, please do not use QWidget::showFullScreen(),
> > QWidget::showMaximized(), QWidget::showMinimized() or
> > QWidget::showNormal(), unless you know what they actually do and you
> > really want that. Which is probably never. For example,
> > QWidget::showNormal() is not an inverse of QWidget:showFullScreen(), and
> > QWidget::showFullScreen() also doesn't just set the window to fullscreen
> > (#157941). I personally consider these to be broken API, although TT
> > apparently doesn't share my opinion.
> >
> >  Use QWidget::setWindowState() as noted above, or some of the helper
> > functions.
>
> I guess the best way to "enforce" this is to add a krazy check for those
> functions and adding an explanation to techbase which the krazy checker can
> link to in its output.

If someone writes the "Qt stuff to avoid" techbase page, I'll write the
corresponding Krazy checker.  I recall someone telling me that
QImage::depth() should be avoided as well... iirc.

BTW: there are over 25000 Krazy issues in trunk/KDE.   Which is pretty high,
historically speaking.




More information about the kde-core-devel mailing list