KDE TechBase
  • Page
  • Discussion
  • Edit
  • History
KDE TechBase is a Wiki - You can help! Please contribute! Questions?
Please ask development related questions in the KDE Community Forum.

Policies/API to Avoid

< Policies

There are classes and functions that should be avoided in KDE applications, but KDE has no direct control over them (for example, they are part of Qt).

Contents

  • 1 API that has KDE replacements
    • 1.1 Qt classes that have their KDE versions
    • 1.2 QSystemTrayIcon::showMessage()
    • 1.3 QHttp
  • 2 API that is considered broken
    • 2.1 QWidget::showFullScreen/Maximized/Minimized/Normal()
  • 3 Further Links

[edit] API that has KDE replacements

[edit] Qt classes that have their KDE versions

KDE applications should not use Qt classes that have their KDE replacements. Examples include QFileDialog, QDialog, QMainWindow. KDE versions of these classes provide better integration with KDE.

[edit] QSystemTrayIcon::showMessage()

Use KNotification for better KDE integration.

[edit] QHttp

QHttp does not respect desktop settings such as the user's proxy settings or resource restrictions. Always use KIO to access network resources.

[edit] API that is considered broken

[edit] QWidget::showFullScreen/Maximized/Minimized/Normal()

Try to avoid calls to QWidget::showFullScreen(), QWidget::showMaximized(), QWidget::showMinimized() and QWidget::showNormal(), use them only if you understand what they do and you really want that. These calls do not only change the relevant window state as most people expect, but they also have other effects. For example, showFullScreen() among other things also removes the maximized state (see bug #157941), the same way showNormal() is not an inverse call to showFullScreen().

Either use QWidget::setWindowState() in the following way

widget->setWindowState(widget->windowState() | Qt::WindowFullScreen); // set
widget->setWindowState(widget->windowState() & ~Qt::WindowFullScreen); // reset

or use KDE API - KToggleFullScreenAction has setFullScreen() helper function, and KWindowSystem has calls for changing window state.

[edit] Further Links

For further programming tips, please read the article about common programming mistakes.

Retrieved from "http://techbase.kde.org/Policies/API_to_Avoid"

Navigation

  • Home
  • Help
  • Recent changes

Sections

  • Getting started
  • Development
  • Schedules
  • Policies
  • Contribute
  • Projects

Toolbox

  • What links here
  • Related changes
  • Special pages
  • Printable version
  • Permanent link

Personal tools

  • 38.107.191.95
  • Talk for this IP
  • Log in / create account
  • Login with OpenID
Creative Commons License SA 3.0 as well as the GNU Free Documentation License 1.2
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal