SlideShare uma empresa Scribd logo
1 de 84
Baixar para ler offline
Agenda

•  Introduction

•  Styles

•  Style sheets

•  Dialogs

•  Cross platform tips

•  Platform specific tips


                            1
Who am I?

•  Jens Bache-Wiig
  –  Qt developer since 2005

  –  Works on look and feel




                               2
3
Introduction

“Media reviews of your product will be more
  positive…”

                         Apple Interface Guidelines




                                                      4
Introduction

•  Platform guidelines
  –  Windows User Experience Interaction Guidelines

  –  Apple Human Interface Guidelines

  –  KDE User Interface Guidelines

  –  GNOME HIG




                                                      5
QStyle




         6
QStyle

•  Appearance

•  Size and shape

•  Any platform specific behavior




                                    7
QStyle

•  Do not force a specific style

•  Ship all available styles
   –  Make sure to compile with GTK+ headers on X11 and
     the Windows Vista SDK on windows

•  Always use the style when implementing custom
  widgets



                                                          8
9
10
QStyle




         11
QStyle

•  What if I need to modify a style?




                                       12
QStyle

•  Don’t subclass it!

•  Use a proxy style




                        13
QStyle

•  QProxyStyle introduced in 4.6
  –  Makes it easy to customize the platform style

  –  Without breaking it 




                                                     14
QStyle




         15
Agenda

•  Introduction

•  Styles

•  Style sheets

•  Dialogs

•  Cross platform tips

•  Platform specific tips


                            16
Style Sheets

•  Use carefully

•  Tends to break look and feel

•  Try to blend with system palette
   –  Use transparency

   –  Use palette colors




                                      17
Style Sheets




               18
Style Sheets

Avoid hardcoding colors
  QString css = "QLabel { color:palette(highlight); }”;

If you need completely custom colors
  QColor color(255, 0, 0);

  QString css = QString("QLabel { color: %1; }").arg(color.name());




                                                                      19
Style sheets

•  How can I make a segmented button?




                                        20
Style sheets




               21
Style sheets




               22
Style sheets

•  Attach a style sheet to a particular style:
QToolButton[style=QMacStyle] {

    border-image: url(:/button_mac.png);

}

QToolButton[style=QWindowsVistaStyle] {

    border-image: url(:/button_vista.png);

}




                                                 23
Style sheets




               24
Agenda

•  Introduction

•  Styles

•  Style sheets

•  Dialogs

•  Cross platform tips

•  Platform specific tips


                            25
Dialogs



   Windows   Mac




   KDE       GNOME




                     26
Dialogs

QDialogButtonBox

 - Manages order, layout, icon and text

 QDialogButtonBox box(QDialogButtonBox::Save |
                     QDalogButtonBox::Discard |
                     QDialogButtonBox::Cancel);




                                                  27
Dialogs

•  Custom buttons are marked with a role
   –  Determines positioning

   –  Reject, accept, help …
QDialogButtonBox box;

box.addButton(myButton, QDialogButtonBox::AcceptRole);




                                                         28
Dialogs

  Traditional modal dialog


  MyQDialogSubclass dialog;

  // Various bits of initialization

  if (dialog.exec() == QDialog::Accept)    {

      // Set new values or do extra work

      // based on results.

  }




                                               29
Dialogs

•  Windows
  –  Use only for critical or infrequent one-off tasks that
    require completion before continuing

•  KDE
  –  Use only if allowing interaction would cause data loss
    or some other serious problem




                                                              30
Dialogs

•  What happens when you open a modal dialog?




                                                31
Dialogs

•  QDialog::show() - non modal

•  QDialog::exec() - modal

•  QDialog::open() – window modal




                                    32
Dialogs

  Using QDialog::open() :




                            33
Dialogs




          34
Dialogs




          35
Dialogs




          36
Agenda

•  Introduction

•  Styles

•  Style sheets

•  Dialogs

•  Cross platform tips

•  Platform specific tips


                            37
Cross platform tips

  How do you tell the user that the current document was
    modified?




                                                           38
Cross platform tips

•  When showing a file location in the title bar


setWindowModified(true);

setWindowFilePath("untitled.txt");




                                                   39
Cross platform tips




                      40
Cross platform tips

  How can your application ask for attention?




                                                41
Cross platform tips

QApplication::alert(widget, msec = 0);

•  Bouncing dock icon on Mac

•  Flashing taskbar entry on Windows




                                         42
Cross platform tips

 •  QSystemTrayIcon
   -use b/w icon on mac




                          43
Cross platform tips

  Where do you store your documents?




                                       44
Cross platform tips

•  QDesktopServices::storageLocation()
  –  gives you default system directories such as
    Desktop, Music, Pictures, Applications, Temp and
    Cache




                                                       45
Cross platform tips

  How can you open an e-mail using your standard e-mail
    application?




                                                          46
Cross platform tips

•  QDesktopServices::openUrl(const QUrl &url)
  –  Launches the provided URL using the default system
    application



  openUrl(“mailto:myself@gmail.com”);

  openUrl(“http://qt.nokia.com”);

  openUrl(QUrl::fromLocalFile(…));



                                                          47
Cross platform tips


  Which shortcut do I use for “find” in a document?




                                                      48
Cross platform tips

•  Depends on your platform!

•  Use standard shortcuts whenever possible

•  Test for conflicts on all platforms


  QAction action;

  action.setShortcuts(QKeySequence::Find);




                                              49
Cross platform tips

// Get a list of all keys for a StandardKey.
  QList<QKeySequence> keys      =
  QKeySequence::keyBindings(QKeySequence::NextChild);
  foreach (QKeySequence key, keys) {

      printOut(key.toString(QKeySequence::PortableText));

} …




                                                            50
Cross platform tips

•  Use a consistent icon theme

•  Lots of free themes available online
    –  Oxygen, Tango to mention a few




http://www.oxygen-icons.org             http://tango.freedesktop.org



                                                                       51
Cross platform tips

•  Icon theme support in 4.6
  QIcon::fromTheme(“document-edit”);

  QIcon::fromTheme(“document-edit”,
    QIcon(“document.png”));




         For previous versions of Qt: http://code.google.com/p/qticonloader/



                                                                               52
Cross platform tips




                      53
Cross platform tips




                      54
Cross platform tips

•  Give your QAction priority
   –  Introduced in 4.6

   –  low, normal and high priority



   QAction::setPriority(QAction::Priority)




                                             55
Cross platform tips




                      56
Cross platform tips




                      57
Cross platform tips

•  Icons in menus
   –  Not visible on Mac

   –  Visible on Windows and KDE

   –  Depends on the system setting in GNOME

•  Override with
   –  QAction::setIconVisibleInMenu(bool)

   –  QApplication::setAttribute(Qt::AA_DontShowIconsInMenus)



                                                                58
Cross platform tips - Dialogs

•  Preferences on GNOME/Mac
  –  Applies immediately

•  Preferences on Windows/KDE
  –  Apply/Cancel




                                59
Cross platform tips

•  MDI interfaces
  –  Mac does not support it

  –  GTK+ does not support it

  –  Microsoft:
     •  SDI is appropriate for most productivity applications. MDI is
       still in use, but does not fit as well with today's users and
       operating systems




                                                                        60
Go native!

•  Ifdef is evil but sometimes useful…
  –  Q_WS_WIN

  –  Q_WS_MAC

  –  Q_WS_X11




                                         61
The window id

  –  QWidget::winId()

  –  Returns a native window handle
     •  HWND on Windows

     •  NSView* on Cocoa

     •  X11 handle

  –  Allows using native API
     •  Windows Vista or Windows 7 specific features




                                                       62
Agenda

•  Introduction

•  Styles

•  Style sheets

•  Dialogs

•  Cross platform tips

•  Platform specific tips


                            63
Platform specific tips




                         64
Mac

 –  MacMainWindow demo




                         65
Mac

•  Icons
   –  Use a high-resolution application icon

   –  Use a b/w system tray icon




                                               66
Mac

•  QMenuBar can stand on it’s own!
  –  Create it without a parent

  –  The first menu bar created will be the default menu bar




                                                               67
Mac

      QMainWindow::setUnifiedTitleAndToolBarOnMac()




                                                      68
Mac

•  Why not allways set it?
   –  Not movable

   –  No breaks are respected

   –  Custom widgets hidden when small

   –  Toolbar hidden in fullscreen




                                         69
Mac

•  Unified toolbar breakage….




                                70
Mac – Doc menu




QMenu*menu = new QMenu;
// Add actions to the menu
// Connect them to slots
    ...
extern void qt_mac_set_dock_menu(QMenu *);
qt_mac_set_dock_menu(menu);



                                             71
Mac

•  Qt automatically rearranges menu entries
  –  Based on name: about, settings, preferences, quit, exit

  –  Override with QAction::menuRole
      •  AboutRole, PreferencesRole, QuitRole, NoRole (do not move)

•  Example
      •  A QMenu entry called “settings” goes to
        Application::preferences on mac




                                                                      72
X11




      73
X11

•  Follow freedesktop.org standards if possible
  –  Menu specs

  –  Icon themes

  –  Autostart

  –  Bookmarks

  –  .desktop file




                                                  74
X11

•  Make a desktop file
  –  standards.freedesktop.org/desktop-entry-spec/

  –  Simple configuration file containing
      •  Application Icon

      •  Menu Entry

      •  Registered mime types

      •  …




                                                     75
X11

•  How do you know if you are running KDE or
  GNOME?
  –  No 100% reliable way of doing it

  –  You can try the “DESKTOP_SESSION” env. variable
      •  “kde”, “gnome”




                                                       76
X11

•  Test on both KDE and GNOME
  –  Different shortcuts

  –  Different themes

  –  Window behavior




                                77
78
Windows tips

•  QSettings uses the windows registry
  –  you can also use QSettings to read system settings

  QSettings settings("HKEY_CURRENT_USER … ExplorerAdvanced”, QSettings::NativeFormat);
  bool result = settings.value("EnableBalloonTips”, true).toBool();




                                                                                             79
Windows tips

•  Try explorer style



 http://labs.trolltech.com/blogs/2007/06/08/explorer-style-toolbars/




                                                                       80
Windows tips

•  QtDotNetStyle
  –  Free solution




                     81
Windows tips

•  Enable blur behind on Vista or windows 7
  –  No API in Qt for this yet

  –  However you can use the windows API directly if you
    set WA_TranslucentBackground and
    WA_NoSystemBackground on the widget!




                                                           82
Windows




          83
Conclusion




             84

Mais conteúdo relacionado

Mais procurados

[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
MinGeun Park
 
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
MinGeun Park
 

Mais procurados (20)

Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
Getting started with Ray Tracing in Unity 2019.3 - Unite Copenhagen 2019
 
Migrating from OpenGL to Vulkan
Migrating from OpenGL to VulkanMigrating from OpenGL to Vulkan
Migrating from OpenGL to Vulkan
 
[2012 대학특강] 아티스트 + 프로그래머
[2012 대학특강] 아티스트 + 프로그래머[2012 대학특강] 아티스트 + 프로그래머
[2012 대학특강] 아티스트 + 프로그래머
 
High dynamic range
High dynamic rangeHigh dynamic range
High dynamic range
 
Ssao
SsaoSsao
Ssao
 
Skia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics EssentialsSkia & Freetype - Android 2D Graphics Essentials
Skia & Freetype - Android 2D Graphics Essentials
 
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
[0107 박민근] 쉽게 배우는 hdr과 톤맵핑
 
이펙트 쉐이더 1강 - Shader 기초 개념
이펙트 쉐이더 1강 - Shader 기초 개념이펙트 쉐이더 1강 - Shader 기초 개념
이펙트 쉐이더 1강 - Shader 기초 개념
 
Spacesaver Products Color Chart
Spacesaver Products Color ChartSpacesaver Products Color Chart
Spacesaver Products Color Chart
 
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
NDC2016 프로젝트 A1의 AAA급 캐릭터 렌더링 기술
 
Myths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven DevelopmentMyths and Challenges of Behaviour Driven Development
Myths and Challenges of Behaviour Driven Development
 
Software development process models
Software development process modelsSoftware development process models
Software development process models
 
Built for performance: the UIElements Renderer – Unite Copenhagen 2019
Built for performance: the UIElements Renderer – Unite Copenhagen 2019Built for performance: the UIElements Renderer – Unite Copenhagen 2019
Built for performance: the UIElements Renderer – Unite Copenhagen 2019
 
Filmic Tonemapping for Real-time Rendering - Siggraph 2010 Color Course
Filmic Tonemapping for Real-time Rendering - Siggraph 2010 Color CourseFilmic Tonemapping for Real-time Rendering - Siggraph 2010 Color Course
Filmic Tonemapping for Real-time Rendering - Siggraph 2010 Color Course
 
Motion blur
Motion blurMotion blur
Motion blur
 
아티스트에게 사랑받는 3DS Max 우버쉐이더
아티스트에게 사랑받는 3DS Max 우버쉐이더아티스트에게 사랑받는 3DS Max 우버쉐이더
아티스트에게 사랑받는 3DS Max 우버쉐이더
 
OpenGL 3.2 and More
OpenGL 3.2 and MoreOpenGL 3.2 and More
OpenGL 3.2 and More
 
Screen Space Decals in Warhammer 40,000: Space Marine
Screen Space Decals in Warhammer 40,000: Space MarineScreen Space Decals in Warhammer 40,000: Space Marine
Screen Space Decals in Warhammer 40,000: Space Marine
 
Architecture of .net framework
Architecture of .net frameworkArchitecture of .net framework
Architecture of .net framework
 
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
[Ndc12] 누구나 알기쉬운 hdr과 톤맵핑 박민근
 

Destaque

Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
Ariya Hidayat
 
Cross platform solutions for Mobile App Development
Cross platform solutions for Mobile App Development Cross platform solutions for Mobile App Development
Cross platform solutions for Mobile App Development
USAID CEED II Project Moldova
 
Cross platform development
Cross platform developmentCross platform development
Cross platform development
dftaiwo
 

Destaque (20)

Creating Slick User Interfaces With Qt
Creating Slick User Interfaces With QtCreating Slick User Interfaces With Qt
Creating Slick User Interfaces With Qt
 
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization SoftwareCase Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
 
Qt Widget In-Depth
Qt Widget In-DepthQt Widget In-Depth
Qt Widget In-Depth
 
Efficient Graphics with Qt
Efficient Graphics with QtEfficient Graphics with Qt
Efficient Graphics with Qt
 
Qt for beginners part 1 overview and key concepts
Qt for beginners part 1   overview and key conceptsQt for beginners part 1   overview and key concepts
Qt for beginners part 1 overview and key concepts
 
Special Effects with Qt Graphics View
Special Effects with Qt Graphics ViewSpecial Effects with Qt Graphics View
Special Effects with Qt Graphics View
 
Optimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based ApplicationsOptimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based Applications
 
Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7Qt and QML performance tips & tricks for Qt 4.7
Qt and QML performance tips & tricks for Qt 4.7
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgets
 
Qt for beginners part 5 ask the experts
Qt for beginners part 5   ask the expertsQt for beginners part 5   ask the experts
Qt for beginners part 5 ask the experts
 
Qt for beginners part 4 doing more
Qt for beginners part 4   doing moreQt for beginners part 4   doing more
Qt for beginners part 4 doing more
 
Qt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt QuickQt for Beginners Part 3 - QML and Qt Quick
Qt for Beginners Part 3 - QML and Qt Quick
 
Qt Application Development on Harmattan
Qt Application Development on HarmattanQt Application Development on Harmattan
Qt Application Development on Harmattan
 
Cross platform solutions for Mobile App Development
Cross platform solutions for Mobile App Development Cross platform solutions for Mobile App Development
Cross platform solutions for Mobile App Development
 
Cross platform development
Cross platform developmentCross platform development
Cross platform development
 
The Mobile Market and Qt
The Mobile Market and QtThe Mobile Market and Qt
The Mobile Market and Qt
 
Building Cross-Platform Apps using Qt and Qyoto
Building Cross-Platform Apps using Qt and QyotoBuilding Cross-Platform Apps using Qt and Qyoto
Building Cross-Platform Apps using Qt and Qyoto
 
Best Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part IIIBest Practices in Qt Quick/QML - Part III
Best Practices in Qt Quick/QML - Part III
 
Best Practices in Qt Quick/QML - Part II
Best Practices in Qt Quick/QML - Part IIBest Practices in Qt Quick/QML - Part II
Best Practices in Qt Quick/QML - Part II
 
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
 

Semelhante a How to Make Your Qt App Look Native

CMake: Improving Software Quality and Process
CMake: Improving Software Quality and ProcessCMake: Improving Software Quality and Process
CMake: Improving Software Quality and Process
Marcus Hanwell
 
90 CADWorx Tips in 90 Minutes - mworland
90 CADWorx Tips in 90 Minutes - mworland 90 CADWorx Tips in 90 Minutes - mworland
90 CADWorx Tips in 90 Minutes - mworland
Matt Worland
 
A Taste of Pharo 7.0
A Taste of Pharo 7.0A Taste of Pharo 7.0
A Taste of Pharo 7.0
ESUG
 
60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final
SE3D
 
60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final
SE3D
 
Swt eye for the swing guy
Swt eye for the swing guySwt eye for the swing guy
Swt eye for the swing guy
Ioan Bogdan
 

Semelhante a How to Make Your Qt App Look Native (20)

CiklumCPPSat: Alexey Podoba "Automatic assembly. Cmake"
CiklumCPPSat: Alexey Podoba "Automatic assembly. Cmake"CiklumCPPSat: Alexey Podoba "Automatic assembly. Cmake"
CiklumCPPSat: Alexey Podoba "Automatic assembly. Cmake"
 
Development with Qt for Windows CE
Development with Qt for Windows CEDevelopment with Qt for Windows CE
Development with Qt for Windows CE
 
Cmake kitware
Cmake kitwareCmake kitware
Cmake kitware
 
CMake: Improving Software Quality and Process
CMake: Improving Software Quality and ProcessCMake: Improving Software Quality and Process
CMake: Improving Software Quality and Process
 
90 CADWorx Tips in 90 Minutes - mworland
90 CADWorx Tips in 90 Minutes - mworland 90 CADWorx Tips in 90 Minutes - mworland
90 CADWorx Tips in 90 Minutes - mworland
 
Использование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложенийИспользование AzureDevOps при разработке микросервисных приложений
Использование AzureDevOps при разработке микросервисных приложений
 
QtQuick Day 1
QtQuick Day 1QtQuick Day 1
QtQuick Day 1
 
Kitware: Qt and Scientific Computing
Kitware: Qt and Scientific ComputingKitware: Qt and Scientific Computing
Kitware: Qt and Scientific Computing
 
A Taste of Pharo 7.0
A Taste of Pharo 7.0A Taste of Pharo 7.0
A Taste of Pharo 7.0
 
Qt programming-using-cpp
Qt programming-using-cppQt programming-using-cpp
Qt programming-using-cpp
 
Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1Qt Application Programming with C++ - Part 1
Qt Application Programming with C++ - Part 1
 
Cross Platform Qt
Cross Platform QtCross Platform Qt
Cross Platform Qt
 
Surviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-studySurviving a Plane Crash, a NU.nl case-study
Surviving a Plane Crash, a NU.nl case-study
 
Free GitOps Workshop
Free GitOps WorkshopFree GitOps Workshop
Free GitOps Workshop
 
60_AutoCAD_Tips_in_60_Minutes_final.ppt
60_AutoCAD_Tips_in_60_Minutes_final.ppt60_AutoCAD_Tips_in_60_Minutes_final.ppt
60_AutoCAD_Tips_in_60_Minutes_final.ppt
 
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech UpdateAdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
AdaCore Paris Tech Day 2016: Jose Ruiz - QGen Tech Update
 
60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final
 
60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final
 
60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final60 auto cad_tips_in_60_minutes_final
60 auto cad_tips_in_60_minutes_final
 
Swt eye for the swing guy
Swt eye for the swing guySwt eye for the swing guy
Swt eye for the swing guy
 

Mais de account inactive

Mais de account inactive (20)

Meet Qt
Meet QtMeet Qt
Meet Qt
 
KDE Plasma for Mobile Phones
KDE Plasma for Mobile PhonesKDE Plasma for Mobile Phones
KDE Plasma for Mobile Phones
 
Shipping Mobile Applications Using Qt for Symbian
Shipping Mobile Applications Using Qt for SymbianShipping Mobile Applications Using Qt for Symbian
Shipping Mobile Applications Using Qt for Symbian
 
The Future of Qt Widgets
The Future of Qt WidgetsThe Future of Qt Widgets
The Future of Qt Widgets
 
Scripting Your Qt Application
Scripting Your Qt ApplicationScripting Your Qt Application
Scripting Your Qt Application
 
Developments in The Qt WebKit Integration
Developments in The Qt WebKit IntegrationDevelopments in The Qt WebKit Integration
Developments in The Qt WebKit Integration
 
Qt Kwan-Do
Qt Kwan-DoQt Kwan-Do
Qt Kwan-Do
 
Qt on Real Time Operating Systems
Qt on Real Time Operating SystemsQt on Real Time Operating Systems
Qt on Real Time Operating Systems
 
Translating Qt Applications
Translating Qt ApplicationsTranslating Qt Applications
Translating Qt Applications
 
Qt Creator Bootcamp
Qt Creator BootcampQt Creator Bootcamp
Qt Creator Bootcamp
 
Qt State Machine Framework
Qt State Machine FrameworkQt State Machine Framework
Qt State Machine Framework
 
Mobile Development with Qt for Symbian
Mobile Development with Qt for SymbianMobile Development with Qt for Symbian
Mobile Development with Qt for Symbian
 
Animation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIsAnimation Framework: A Step Towards Modern UIs
Animation Framework: A Step Towards Modern UIs
 
Using Multi-Touch and Gestures with Qt
Using Multi-Touch and Gestures with QtUsing Multi-Touch and Gestures with Qt
Using Multi-Touch and Gestures with Qt
 
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
 
The Mobility Project
The Mobility ProjectThe Mobility Project
The Mobility Project
 
Copy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with QtCopy Your Favourite Nokia App with Qt
Copy Your Favourite Nokia App with Qt
 
The Next Generation Qt Item Views
The Next Generation Qt Item ViewsThe Next Generation Qt Item Views
The Next Generation Qt Item Views
 
Qt Licensing Explained
Qt Licensing ExplainedQt Licensing Explained
Qt Licensing Explained
 
Case Study: Porting Qt for Embedded Linux on Embedded Processors
Case Study: Porting Qt for Embedded Linux on Embedded ProcessorsCase Study: Porting Qt for Embedded Linux on Embedded Processors
Case Study: Porting Qt for Embedded Linux on Embedded Processors
 

Último

Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Victor Rentea
 

Último (20)

Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 

How to Make Your Qt App Look Native

  • 1. Agenda •  Introduction •  Styles •  Style sheets •  Dialogs •  Cross platform tips •  Platform specific tips 1
  • 2. Who am I? •  Jens Bache-Wiig –  Qt developer since 2005 –  Works on look and feel 2
  • 3. 3
  • 4. Introduction “Media reviews of your product will be more positive…” Apple Interface Guidelines 4
  • 5. Introduction •  Platform guidelines –  Windows User Experience Interaction Guidelines –  Apple Human Interface Guidelines –  KDE User Interface Guidelines –  GNOME HIG 5
  • 6. QStyle 6
  • 7. QStyle •  Appearance •  Size and shape •  Any platform specific behavior 7
  • 8. QStyle •  Do not force a specific style •  Ship all available styles –  Make sure to compile with GTK+ headers on X11 and the Windows Vista SDK on windows •  Always use the style when implementing custom widgets 8
  • 9. 9
  • 10. 10
  • 11. QStyle 11
  • 12. QStyle •  What if I need to modify a style? 12
  • 13. QStyle •  Don’t subclass it! •  Use a proxy style 13
  • 14. QStyle •  QProxyStyle introduced in 4.6 –  Makes it easy to customize the platform style –  Without breaking it  14
  • 15. QStyle 15
  • 16. Agenda •  Introduction •  Styles •  Style sheets •  Dialogs •  Cross platform tips •  Platform specific tips 16
  • 17. Style Sheets •  Use carefully •  Tends to break look and feel •  Try to blend with system palette –  Use transparency –  Use palette colors 17
  • 19. Style Sheets Avoid hardcoding colors QString css = "QLabel { color:palette(highlight); }”; If you need completely custom colors QColor color(255, 0, 0); QString css = QString("QLabel { color: %1; }").arg(color.name()); 19
  • 20. Style sheets •  How can I make a segmented button? 20
  • 23. Style sheets •  Attach a style sheet to a particular style: QToolButton[style=QMacStyle] { border-image: url(:/button_mac.png); } QToolButton[style=QWindowsVistaStyle] { border-image: url(:/button_vista.png); } 23
  • 25. Agenda •  Introduction •  Styles •  Style sheets •  Dialogs •  Cross platform tips •  Platform specific tips 25
  • 26. Dialogs Windows Mac KDE GNOME 26
  • 27. Dialogs QDialogButtonBox - Manages order, layout, icon and text QDialogButtonBox box(QDialogButtonBox::Save | QDalogButtonBox::Discard | QDialogButtonBox::Cancel); 27
  • 28. Dialogs •  Custom buttons are marked with a role –  Determines positioning –  Reject, accept, help … QDialogButtonBox box; box.addButton(myButton, QDialogButtonBox::AcceptRole); 28
  • 29. Dialogs Traditional modal dialog MyQDialogSubclass dialog; // Various bits of initialization if (dialog.exec() == QDialog::Accept) { // Set new values or do extra work // based on results. } 29
  • 30. Dialogs •  Windows –  Use only for critical or infrequent one-off tasks that require completion before continuing •  KDE –  Use only if allowing interaction would cause data loss or some other serious problem 30
  • 31. Dialogs •  What happens when you open a modal dialog? 31
  • 32. Dialogs •  QDialog::show() - non modal •  QDialog::exec() - modal •  QDialog::open() – window modal 32
  • 33. Dialogs Using QDialog::open() : 33
  • 34. Dialogs 34
  • 35. Dialogs 35
  • 36. Dialogs 36
  • 37. Agenda •  Introduction •  Styles •  Style sheets •  Dialogs •  Cross platform tips •  Platform specific tips 37
  • 38. Cross platform tips How do you tell the user that the current document was modified? 38
  • 39. Cross platform tips •  When showing a file location in the title bar setWindowModified(true); setWindowFilePath("untitled.txt"); 39
  • 41. Cross platform tips How can your application ask for attention? 41
  • 42. Cross platform tips QApplication::alert(widget, msec = 0); •  Bouncing dock icon on Mac •  Flashing taskbar entry on Windows 42
  • 43. Cross platform tips •  QSystemTrayIcon -use b/w icon on mac 43
  • 44. Cross platform tips Where do you store your documents? 44
  • 45. Cross platform tips •  QDesktopServices::storageLocation() –  gives you default system directories such as Desktop, Music, Pictures, Applications, Temp and Cache 45
  • 46. Cross platform tips How can you open an e-mail using your standard e-mail application? 46
  • 47. Cross platform tips •  QDesktopServices::openUrl(const QUrl &url) –  Launches the provided URL using the default system application openUrl(“mailto:myself@gmail.com”); openUrl(“http://qt.nokia.com”); openUrl(QUrl::fromLocalFile(…)); 47
  • 48. Cross platform tips Which shortcut do I use for “find” in a document? 48
  • 49. Cross platform tips •  Depends on your platform! •  Use standard shortcuts whenever possible •  Test for conflicts on all platforms QAction action; action.setShortcuts(QKeySequence::Find); 49
  • 50. Cross platform tips // Get a list of all keys for a StandardKey. QList<QKeySequence> keys = QKeySequence::keyBindings(QKeySequence::NextChild); foreach (QKeySequence key, keys) { printOut(key.toString(QKeySequence::PortableText)); } … 50
  • 51. Cross platform tips •  Use a consistent icon theme •  Lots of free themes available online –  Oxygen, Tango to mention a few http://www.oxygen-icons.org http://tango.freedesktop.org 51
  • 52. Cross platform tips •  Icon theme support in 4.6 QIcon::fromTheme(“document-edit”); QIcon::fromTheme(“document-edit”, QIcon(“document.png”)); For previous versions of Qt: http://code.google.com/p/qticonloader/ 52
  • 55. Cross platform tips •  Give your QAction priority –  Introduced in 4.6 –  low, normal and high priority QAction::setPriority(QAction::Priority) 55
  • 58. Cross platform tips •  Icons in menus –  Not visible on Mac –  Visible on Windows and KDE –  Depends on the system setting in GNOME •  Override with –  QAction::setIconVisibleInMenu(bool) –  QApplication::setAttribute(Qt::AA_DontShowIconsInMenus) 58
  • 59. Cross platform tips - Dialogs •  Preferences on GNOME/Mac –  Applies immediately •  Preferences on Windows/KDE –  Apply/Cancel 59
  • 60. Cross platform tips •  MDI interfaces –  Mac does not support it –  GTK+ does not support it –  Microsoft: •  SDI is appropriate for most productivity applications. MDI is still in use, but does not fit as well with today's users and operating systems 60
  • 61. Go native! •  Ifdef is evil but sometimes useful… –  Q_WS_WIN –  Q_WS_MAC –  Q_WS_X11 61
  • 62. The window id –  QWidget::winId() –  Returns a native window handle •  HWND on Windows •  NSView* on Cocoa •  X11 handle –  Allows using native API •  Windows Vista or Windows 7 specific features 62
  • 63. Agenda •  Introduction •  Styles •  Style sheets •  Dialogs •  Cross platform tips •  Platform specific tips 63
  • 66. Mac •  Icons –  Use a high-resolution application icon –  Use a b/w system tray icon 66
  • 67. Mac •  QMenuBar can stand on it’s own! –  Create it without a parent –  The first menu bar created will be the default menu bar 67
  • 68. Mac QMainWindow::setUnifiedTitleAndToolBarOnMac() 68
  • 69. Mac •  Why not allways set it? –  Not movable –  No breaks are respected –  Custom widgets hidden when small –  Toolbar hidden in fullscreen 69
  • 70. Mac •  Unified toolbar breakage…. 70
  • 71. Mac – Doc menu QMenu*menu = new QMenu; // Add actions to the menu // Connect them to slots ... extern void qt_mac_set_dock_menu(QMenu *); qt_mac_set_dock_menu(menu); 71
  • 72. Mac •  Qt automatically rearranges menu entries –  Based on name: about, settings, preferences, quit, exit –  Override with QAction::menuRole •  AboutRole, PreferencesRole, QuitRole, NoRole (do not move) •  Example •  A QMenu entry called “settings” goes to Application::preferences on mac 72
  • 73. X11 73
  • 74. X11 •  Follow freedesktop.org standards if possible –  Menu specs –  Icon themes –  Autostart –  Bookmarks –  .desktop file 74
  • 75. X11 •  Make a desktop file –  standards.freedesktop.org/desktop-entry-spec/ –  Simple configuration file containing •  Application Icon •  Menu Entry •  Registered mime types •  … 75
  • 76. X11 •  How do you know if you are running KDE or GNOME? –  No 100% reliable way of doing it –  You can try the “DESKTOP_SESSION” env. variable •  “kde”, “gnome” 76
  • 77. X11 •  Test on both KDE and GNOME –  Different shortcuts –  Different themes –  Window behavior 77
  • 78. 78
  • 79. Windows tips •  QSettings uses the windows registry –  you can also use QSettings to read system settings QSettings settings("HKEY_CURRENT_USER … ExplorerAdvanced”, QSettings::NativeFormat); bool result = settings.value("EnableBalloonTips”, true).toBool(); 79
  • 80. Windows tips •  Try explorer style http://labs.trolltech.com/blogs/2007/06/08/explorer-style-toolbars/ 80
  • 81. Windows tips •  QtDotNetStyle –  Free solution 81
  • 82. Windows tips •  Enable blur behind on Vista or windows 7 –  No API in Qt for this yet –  However you can use the windows API directly if you set WA_TranslucentBackground and WA_NoSystemBackground on the widget! 82
  • 83. Windows 83