Qt Widgets In-Depth
    QWidget Under The Surface
About Me

• Marius Bugge Monsen
• Qt Developer
• Qt Widgets Team Lead
• Widgets and Window Systems
• Flags and Attributes
• The Future of Qt Widgets
by extranoise on flickr




Widgets and Window Systems
• Widgets and Window Systems
 • Window Systems
 • Windows and Widgets
 • Updates and Painting
 • Events and Loops
• Widgets and Window Systems
 • Window Systems
 • Windows and Widgets
 • Updates and Painting
 • Events and Loops
QWS       SunView
MiniGUI                             Metisse
     Rio    Microwindows
DM                          Fresco/Berlin
     8 1/2 GEM                        ManaGeR
HP Windows                  OOHG
               Xynth
                        MicroXwin       Intuition
Y             FBUI
     NeWS
                     NeXT DPS           Quartz
Wayland      Twin
                     OPIE           X
• X11
• Desktop Window Manager (MS Windows)
• Quartz Compositor (Mac OS X)
• QWS
• S60 Window Manager
Window Surface
Surface


Surface
Screen
Window System
Window System
Window System         Qt Application


                IPC     #include<QtGui>
                        int main(int argc, char *argv[])
                        {
                          QApplication a(argc,argv);
                          QWidget w;
                          w.show();
                          return a.exec();
                        }
• Widgets and Window Systems
 • Window Systems
 • Windows and Widgets
 • Updates and Painting
 • Events and Loops
Surface


          Surface


Surface
Surface


Surface             Surface
Qt Widget In-Depth
Widget


         Window


Widget
Window
• Widgets and Window Systems
 • Window Systems
 • Windows and Widgets
 • Updates and Painting
 • Events and Loops
Window System   Paint    Painting Code
                            #include<QtGui>
                            int main(int argc, char
                            *argv[])
                            {
                              QApplication a
                            (argc,argv);
                              QWidget w;
                              w.show();
                              return a.exec();
                            }




                Update
Window System   Backing Store   Painting Code
                                   #include<QtGui>
                                   int main(int argc, char
                                   *argv[])
                                   {
                                     QApplication a
                                   (argc,argv);
                                     QWidget w;
                                     w.show();
                                     return a.exec();
                                   }
Text


Text
Text


Text
• Client Side
 • Top-Level Window
   • Backing Store
   • Pixmap
• Server Side
 • Window
 • Pixmap
• Client Side        • Server Side
 • Window             • Window
   • Backing Store    • Pixmap
   • Pixmap
void QWidgetPrivate::drawWidget(QPaintDevice *pdev,
                                     const QRegion &rgn,
                                     const QPoint &offset,
                                     int flags,
                                     QPainter *sharedPainter,
                                     QWidgetBackingStore
*backingStore)
{
   ...
        //actually send the paint event
        QPaintEvent e(toBePainted);
        QCoreApplication::sendSpontaneousEvent(q, &e);
  ...
}
• Widgets and Window Systems
 • Window Systems
 • Windows and Widgets
 • Updates and Painting
 • Events and Loops
• Spontaneous Events
• Application Events
Input   Event   bool W::event(QEvent *e)
                      {

Any                     if (e->type() == t)
                            foobar();
                        return false;
                      }
Window System      Socket       Qt Event Dispatcher Event Handler
                                                        bool
                                                        W::event
                                                        (QEvent *e)
                                                        {
                                                          if (e-
                                                        >type() ==




                Qt Event Loop
int QCoreApplication::exec()
{
   ...
   QEventLoop eventLoop;
   self->d_func()->in_exec = true;
   self->d_func()->aboutToQuitEmitted = false;
   int returnCode = eventLoop.exec();
   ...
}
int QEventLoop::exec(ProcessEventsFlags flags)
{
   ...
   try {
       while (!d->exit)
         processEvents(flags | WaitForMoreEvents
                            | EventLoopExec);
   } catch (...) {
   ...
   --d->threadData->loopLevel;
   return d->returnCode;
}
bool QEventLoop::processEvents(ProcessEventsFlags flags)
{
  Q_D(QEventLoop);
  if (!d->threadData->eventDispatcher)
      return false;
  if (flags & DeferredDeletion)
      QCoreApplication::sendPostedEvents(0,
         QEvent::DeferredDelete);
  return d->threadData->eventDispatcher->processEvents(flags);
}
bool QEventDispatcherUNIX::processEvents
(QEventLoop::ProcessEventsFlags flags)
{
  ...
  // we are awake, broadcast it
  emit awake();
  QCoreApplicationPrivate::sendPostedEvents(0, 0,
      d->threadData);
  ...
  nevents = d->doSelect(flags, tm);
  ...
}
int QEventDispatcherUNIXPrivate::doSelect(
   QEventLoop::ProcessEventsFlags flags, timeval *timeout)
{
   ...
   // Process timers and socket notifiers - the common UNIX stuff
   ...
       nsel = q->select(highest + 1,
                  &sn_vec[0].select_fds,
                  &sn_vec[1].select_fds,
                  &sn_vec[2].select_fds,
                  timeout);
   ...
}
int QEventDispatcherUNIX::select(int nfds,
                                     fd_set *readfds,
                                     fd_set *writefds,
                                     fd_set *exceptfds,
                                     timeval *timeout)
{
   return qt_safe_select(nfds, readfds, writefds, exceptfds, timeout);
}
int qt_safe_select(int nfds,
                       fd_set *fdread,
                       fd_set *fdwrite,
                       fd_set *fdexcept,
                       const struct timeval *orig_timeout)
{
   ...
   // loop and recalculate the timeout as needed
   int ret;
   forever {
       ret = ::select(nfds, fdread, fdwrite, fdexcept, &timeout);
       if (ret != -1 || errno != EINTR)
           return ret;
       // recalculate the timeout
       ...
   }
}
• select()
 • poll status of file descriptors
 • blocks until timeout
X11      Socket       XLib Queue   Qt Event Dispatcher Event Handler
                                                           bool
                                                           W::event
                                                           (QEvent *e)
                                                           {
                                                             if (e-
                                                           >type() ==




      Qt Event Loop
postEvent()       Qt Event Queue   Event Loop   Event Handler
   #include<Q                                       bool
   tGui>                                            W::event
   int main(int                                     (QEvent *e)
   argc, char                                       {
   *argv[])                                           if (e-
   {                                                >type() ==
sendEvent()       Event Handler
   #include<Q         bool
   tGui>              W::event
   int main(int       (QEvent *e)
   argc, char         {
   *argv[])             if (e-
   {                  >type() ==
• Event Propagation
D

A

    C
        B
D


    C


A       B
D


    C


A       B
D


    C


A       B
D


    C


A       B
bool QApplication::notify(QObject *receiver, QEvent *e)
{
  ...
  bool res = false;
  if (!receiver->isWidgetType()) {
      res = d->notify_helper(receiver, e);
  } else switch (e->type()) {
  ...
}
• Widgets Propagate Events
...
case QEvent::StatusTip:
case QEvent::WhatsThisClicked:
    {
        QWidget *w = static_cast<QWidget *>(receiver);
        while (w) {
          res = d->notify_helper(w, e);
          if ((res && e->isAccepted()) || w->isWindow())
              break;
          w = w->parentWidget();
        }
    }
    break;
    ...
• Input Events Are Propagated
• Input Events are propagated if
 • event->isAccepted() == false
 • receiver->event(e) == false
bool QCoreApplicationPrivate::notify_helper(QObject *receiver,
                                            QEvent * event)
{
  // send to all application event filters
  if (sendThroughApplicationEventFilters(receiver, event))
      return true;
  // send to all receiver event filters
  if (sendThroughObjectEventFilters(receiver, event))
      return true;
  // deliver the event
  return receiver->event(event);
}
by Dan Queiroz on flickr




Flags and Attributes
• Flags and Attributes
 • Window Types
 • Window Hints
 • Widget States
 • Widget Attributes
• QWidget
 • QPaintDevice
 • QObject
• QWindowSurface
• Flags and Attributes
 • Window Types
 • Window Hints
 • Widget States
 • Widget Attributes
• Window Types
 • Widget
 • Window
•   Dialog

•   Sheet (Mac)

•   Drawer (Mac)

•   Popup

•   ToolTip

•   SplashScreen

•   Desktop

•   SubWindow (MDI)
Qt Widget In-Depth
• Flags and Attributes
 • Window Types
 • Window Hints
 • Widget States
 • Widget Attributes
•   CustomizeWindowHint           •   MacWindowToolBarButtonHint

•   WindowTitleHint               •   BypassGraphicsProxyWidget

•   WindowSystemMenuHint          •   WindowShadeButtonHint

•   WindowMinimizeButtonHint      •   WindowStaysOnTopHint

•   WindowMaximizeButtonHint      •   WindowStaysOnBottomHint

•   WindowMinMaxButtonHint        •   WindowOkButtonHint (WinCE)

•   WindowCloseButtonHint         •   WindowCancelButtonHint (WinCE)

•   WindowContextHelpButtonHint
• Flags and Attributes
 • Window Types
 • Window Hints
 • Widget States
 • Widget Attributes
• WindowState
 • WindowNoState
 • WindowMinimized
 • WindowMaximized
 • WindowFullScreen
 • WindowActive
• Flags and Attributes
 • Window Types
 • Window Hints
 • Widget States
 • Widget Attributes
• Qt::Widget Attribute
 • 124 Attributes
 • setAttribute()
 • testAttribute()
• Qt::WA_AcceptDrops
• QWidget::setAcceptDrops()
by robclimbing on flickr




Tips and Tricks
• Qt::WA_StaticContents
Exposed
Static Contents




    Exposed
• Qt::WA_NoSystemBackground
• Qt::WA_OpaquePaintEvent
• QWidget::autoFillBackground
• Qt::WA_OpaquePaintEvent
Qt Widget In-Depth
• QWidget::scroll()
 • QWidget::autoFillBackground
 • Qt::WA_OpaquePaintEvent
Concealed




Scrolled




Exposed
• Qt::WA_TranslucentBackground
#include <QtGui>

int main(int argc, char *argv[])
{
   QApplication app(argc, argv);
   QPixmap skin("transparency.png");
   QLabel widget;
   widget.setPixmap(skin);
   widget.setWindowFlags(Qt::Window
                             |Qt::CustomizeWindowHint
                             |Qt::FramelessWindowHint);
   widget.setAttribute(Qt::WA_TranslucentBackground);
   widget.resize(skin.size());
   widget.show();
   return app.exec();
}
Qt Widget In-Depth
by jeff_c on flickr




The Future of Qt Widgets
• The story of two APIs ...
• QWidget
 • Widget Hierarchy
• QGraphicsItem
 • Scene Graph
• QWidget
 • Alien Widgets
 • Graphics Effects
 • Disable Clipping ?
 • Disable Move Events ?
 • Transformations ?
• Is it possible ?
• Is it possible in Qt 4.x ?
Thank you!

Questions?
Bonus Material
Qt Developer Days
 Window System
Window Surface   Scene Graph   IPC
QSharedMemory QGraphicsScene   QTcpSocket
• Server
• Window
• Server
 • Connections
 • Scene Graph
• Window
 • Surface
 • Geometry
 • Id
Server       Client

         #include<QtGui>
         int main(int argc, char *argv[])
         {
           QApplication a(argc,argv);
           QWidget w;
           w.show();
           return a.exec();
         }
Server   Protocol       Client




           ?
                    #include<QtGui>
                    int main(int argc, char *argv[])
                    {
                      QApplication a(argc,argv);
                      QWidget w;
                      w.show();
                      return a.exec();
                    }
• Message
 • Request
 • Reply
 • Event
Request    #include<QtGui>
           int main(int argc, char
           *argv[])
           {
             QApplication a
           (argc,argv);
             QWidget w;
             w.show();
             return a.exec();
           }




Response   #include<QtGui>
           int main(int argc, char
           *argv[])
           {
             QApplication a
           (argc,argv);
             QWidget w;
             w.show();
             return a.exec();
           }
Event   bool W::event(QEvent *e)
        {
          if (e->type() == t)
              foobar();
          return false;
        }
Lighthouse
• Research!
• Qt Graphicssystem Interface
• Makes Qt ports easy
• QGraphicsSystem
• QGraphicsSystemScreen
• QWindowSurface
• QGraphicsSystem
 • Window Surfaces
 • Server Communication
• QGraphicsSystemScreen
 • Screen Information
   • Depth
   • Resolution
   • Size
• QWindowSurface
 • Surface
 • Geometry
 • Id
Demo
Source Code


•   git://gitorious.org/+qt-developers/qt/lighthouse.git

More Related Content

PDF
05 - Qt External Interaction and Graphics
PDF
Scripting Your Qt Application
PDF
A Brief Introduction to the Qt Application Framework
PDF
Petri Niemi Qt Advanced Part 2
PPTX
Untitled presentation(4)
PDF
QThreads: Are You Using Them Wrong?
 
PDF
Qt multi threads
PDF
Qt on Real Time Operating Systems
05 - Qt External Interaction and Graphics
Scripting Your Qt Application
A Brief Introduction to the Qt Application Framework
Petri Niemi Qt Advanced Part 2
Untitled presentation(4)
QThreads: Are You Using Them Wrong?
 
Qt multi threads
Qt on Real Time Operating Systems

What's hot (19)

PDF
Special Effects with Qt Graphics View
ODP
Qt Workshop
PDF
Necessitas - Qt on Android - from FSCONS 2011
PDF
Using Multi-Touch and Gestures with Qt
ODP
Cross Platform Qt
PPTX
Qt Framework Events Signals Threads
PDF
Petri Niemi Qt Advanced Part 1
PPTX
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
PDF
03 - Qt UI Development
PDF
Building the QML Run-time
PDF
QVariant, QObject — Qt's not just for GUI development
 
PDF
The Future of Qt Widgets
PDF
02 - Basics of Qt
PDF
Qt Graphics View Framework (Qt Developers Meetup Isreal)
PDF
Qt for Beginners Part 3 - QML and Qt Quick
 
PDF
State of the Art OpenGL and Qt
 
PDF
Meet the Widgets: Another Way to Implement UI
 
PDF
Copy Your Favourite Nokia App with Qt
PDF
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
Special Effects with Qt Graphics View
Qt Workshop
Necessitas - Qt on Android - from FSCONS 2011
Using Multi-Touch and Gestures with Qt
Cross Platform Qt
Qt Framework Events Signals Threads
Petri Niemi Qt Advanced Part 1
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
03 - Qt UI Development
Building the QML Run-time
QVariant, QObject — Qt's not just for GUI development
 
The Future of Qt Widgets
02 - Basics of Qt
Qt Graphics View Framework (Qt Developers Meetup Isreal)
Qt for Beginners Part 3 - QML and Qt Quick
 
State of the Art OpenGL and Qt
 
Meet the Widgets: Another Way to Implement UI
 
Copy Your Favourite Nokia App with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
Ad

Viewers also liked (20)

PDF
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
PDF
Creating Slick User Interfaces With Qt
PDF
How to Make Your Qt App Look Native
PDF
The Future of Qt Widgets
PDF
Efficient Graphics with Qt
PDF
Optimizing Performance in Qt-Based Applications
PPTX
Tdc2011 goiânia-web apps-30102011
PDF
Shipping Mobile Applications Using Qt for Symbian
PDF
Qt and QML performance tips & tricks for Qt 4.7
PDF
Qt Animation
PDF
Qt for beginners part 2 widgets
 
PPTX
Qt for beginners part 5 ask the experts
 
PDF
Qt for beginners part 4 doing more
 
PPTX
Shortcodes vs Widgets: Which one and how?
PPTX
Qt for beginners part 1 overview and key concepts
 
PDF
Best Practices in Qt Quick/QML - Part II
 
PDF
Best Practices in Qt Quick/QML - Part III
 
PDF
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
 
PDF
Best Practices in Qt Quick/QML - Part IV
 
PPTX
Best Practices in Qt Quick/QML - Part I
 
Case Study: Using Qt to Develop Advanced GUIs & Advanced Visualization Software
Creating Slick User Interfaces With Qt
How to Make Your Qt App Look Native
The Future of Qt Widgets
Efficient Graphics with Qt
Optimizing Performance in Qt-Based Applications
Tdc2011 goiânia-web apps-30102011
Shipping Mobile Applications Using Qt for Symbian
Qt and QML performance tips & tricks for Qt 4.7
Qt Animation
Qt for beginners part 2 widgets
 
Qt for beginners part 5 ask the experts
 
Qt for beginners part 4 doing more
 
Shortcodes vs Widgets: Which one and how?
Qt for beginners part 1 overview and key concepts
 
Best Practices in Qt Quick/QML - Part II
 
Best Practices in Qt Quick/QML - Part III
 
[Webinar] 10 Keys to Ensuring Success for Your Next Qt Project
 
Best Practices in Qt Quick/QML - Part IV
 
Best Practices in Qt Quick/QML - Part I
 
Ad

Similar to Qt Widget In-Depth (20)

PDF
Qt Application Programming with C++ - Part 2
PDF
Qt & Webkit
PDF
#JavaFX.forReal() - ElsassJUG
PDF
[C++ gui programming with qt4] chap9
PDF
Best Practices in Qt Quick/QML - Part 1 of 4
 
DOCX
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
PDF
The Ring programming language version 1.2 book - Part 60 of 84
PPT
Евгений Крутько, Многопоточные вычисления, современный подход.
PDF
writing-custom-qtquickcomponents-QtCon.pdf
PDF
The Ring programming language version 1.9 book - Part 111 of 210
PDF
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
PPTX
Qt coin3d soqt
PDF
Apache PIG - User Defined Functions
PDF
Andes open cl for RISC-V
PDF
Multi qubit entanglement
PDF
Online Meetup: Why should container system / platform builders care about con...
PPTX
Bucks County Tech Meetup: node.js introduction
KEY
Unit testing en iOS @ MobileCon Galicia
PPT
Qt Programming on TI Processors
PDF
The Ring programming language version 1.7 book - Part 101 of 196
Qt Application Programming with C++ - Part 2
Qt & Webkit
#JavaFX.forReal() - ElsassJUG
[C++ gui programming with qt4] chap9
Best Practices in Qt Quick/QML - Part 1 of 4
 
In Class AssignmetzCST280W13a-1.pdfCST 280 In-Class Pract.docx
The Ring programming language version 1.2 book - Part 60 of 84
Евгений Крутько, Многопоточные вычисления, современный подход.
writing-custom-qtquickcomponents-QtCon.pdf
The Ring programming language version 1.9 book - Part 111 of 210
如何透過 Go-kit 快速搭建微服務架構應用程式實戰
Qt coin3d soqt
Apache PIG - User Defined Functions
Andes open cl for RISC-V
Multi qubit entanglement
Online Meetup: Why should container system / platform builders care about con...
Bucks County Tech Meetup: node.js introduction
Unit testing en iOS @ MobileCon Galicia
Qt Programming on TI Processors
The Ring programming language version 1.7 book - Part 101 of 196

More from account inactive (20)

ODP
PDF
KDE Plasma for Mobile Phones
PDF
Developments in The Qt WebKit Integration
PDF
Qt Kwan-Do
PDF
Development with Qt for Windows CE
PDF
Translating Qt Applications
PDF
Qt Creator Bootcamp
PDF
Qt State Machine Framework
PDF
Mobile Development with Qt for Symbian
PPT
Animation Framework: A Step Towards Modern UIs
PDF
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
PDF
The Mobility Project
PDF
The Next Generation Qt Item Views
PDF
Qt Licensing Explained
PDF
Case Study: Porting Qt for Embedded Linux on Embedded Processors
PDF
OGRE: Qt & OGRE for Multimedia Creation
PDF
HGZ Kaffeemaschinen & Qt Speak Coffee
PDF
Discover Qt Learning and Certification
PDF
Accelerating performance on Qt and WebKit for the MIPS architecture
PDF
Qt Experiences on NXP's Connetcted TV Platforms
KDE Plasma for Mobile Phones
Developments in The Qt WebKit Integration
Qt Kwan-Do
Development with Qt for Windows CE
Translating Qt Applications
Qt Creator Bootcamp
Qt State Machine Framework
Mobile Development with Qt for Symbian
Animation Framework: A Step Towards Modern UIs
Debugging Qt, Fixing and Contributing a Bug Report (Using Gitorious)
The Mobility Project
The Next Generation Qt Item Views
Qt Licensing Explained
Case Study: Porting Qt for Embedded Linux on Embedded Processors
OGRE: Qt & OGRE for Multimedia Creation
HGZ Kaffeemaschinen & Qt Speak Coffee
Discover Qt Learning and Certification
Accelerating performance on Qt and WebKit for the MIPS architecture
Qt Experiences on NXP's Connetcted TV Platforms

Recently uploaded (20)

PDF
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
PDF
Enhancing plagiarism detection using data pre-processing and machine learning...
PDF
sbt 2.0: go big (Scala Days 2025 edition)
PDF
Improvisation in detection of pomegranate leaf disease using transfer learni...
PDF
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
PPTX
MuleSoft-Compete-Deck for midddleware integrations
DOCX
Basics of Cloud Computing - Cloud Ecosystem
PPTX
Module 1 Introduction to Web Programming .pptx
PDF
Consumable AI The What, Why & How for Small Teams.pdf
PDF
Flame analysis and combustion estimation using large language and vision assi...
PDF
Taming the Chaos: How to Turn Unstructured Data into Decisions
PDF
Statistics on Ai - sourced from AIPRM.pdf
PPTX
Microsoft User Copilot Training Slide Deck
PDF
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
PDF
sustainability-14-14877-v2.pddhzftheheeeee
PDF
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
PPTX
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
PPT
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
PPTX
Custom Battery Pack Design Considerations for Performance and Safety
PPTX
Training Program for knowledge in solar cell and solar industry
Produktkatalog für HOBO Datenlogger, Wetterstationen, Sensoren, Software und ...
Enhancing plagiarism detection using data pre-processing and machine learning...
sbt 2.0: go big (Scala Days 2025 edition)
Improvisation in detection of pomegranate leaf disease using transfer learni...
Accessing-Finance-in-Jordan-MENA 2024 2025.pdf
MuleSoft-Compete-Deck for midddleware integrations
Basics of Cloud Computing - Cloud Ecosystem
Module 1 Introduction to Web Programming .pptx
Consumable AI The What, Why & How for Small Teams.pdf
Flame analysis and combustion estimation using large language and vision assi...
Taming the Chaos: How to Turn Unstructured Data into Decisions
Statistics on Ai - sourced from AIPRM.pdf
Microsoft User Copilot Training Slide Deck
Transform-Your-Streaming-Platform-with-AI-Driven-Quality-Engineering.pdf
sustainability-14-14877-v2.pddhzftheheeeee
Transform-Quality-Engineering-with-AI-A-60-Day-Blueprint-for-Digital-Success.pdf
AI-driven Assurance Across Your End-to-end Network With ThousandEyes
Galois Field Theory of Risk: A Perspective, Protocol, and Mathematical Backgr...
Custom Battery Pack Design Considerations for Performance and Safety
Training Program for knowledge in solar cell and solar industry

Qt Widget In-Depth