SlideShare a Scribd company logo
Introduction to Qt
 The IDE for C++
THE QT STORY

   Haavard Nord and Eirik Chambe-Eng (the original
    developers of Qt and the CEO and President, respectively, of
    Trolltech) began development of "Qt" in 1991, three years
    before the company was incorporated as Quasar
    Technologies, then changed the name to Troll Tech and then
    to Trolltech.
   Qt is developed by an open source project, the Qt Project,
    involving both individual developers as well as developers
    from Nokia, Digia, and other companies interested in the
    development of Qt.
   The Qt toolkit is a multi-platform C++ GUI toolkit (class library) that has
    been developed over a 6 year period.
   The company Troll Tech AS was founded in 1994 to secure future
    development of Qt.
   On May 20, 1995, Qt was made available under commercial and non-
    commercial GNU licenses. The non-commercial license grants any
    developer the right to use Qt to develop software for the free software
    community.
   It was ten months before the first commercial license was purchased.
    The European Space Agency purchased the second.
   Around 1997, Qt was chosen as the code basis for the KDE linux
    desktop environment.
   Qt 3.0 was released in 2001 with Windows, Unix, Linux, Embedded
    Linux, and Mac OS X libraries.
WHY CROSS-PLATFORM GUI TOOLKITS

 Increases target market.
 May provides the same look-and-feel across
  platform. Reduces training and documentation
  costs.
STATEGIES FOR IMPLEMENTING CROSS-PLATFORM GUIS


   API Layering – Mapping one API to many others
     Example – wxWindows – Win32 API on top of Motif or
      Xt API under Unix.
     Advantages – easy to write, 100% compatible native
      look and feel.
     Disadvantages –
         slower

         problems  mapping to vastly different API architectures
         Lowest common denominator – i.e. no pop-up help anywhere

         Objects required a C++ wrapper to work with them in C++
QT ASSISTANT
   All documentation is
    available through the
    trolltech web site.
   Qt Assistant is a Qt help
    browser that runs under
    Windows.
   It has with search and
    indexing features that make
    it quicker and easier than the
    web.
`QT DESIGNER
   Widgets and forms
    created with Qt Designer
    integrated seamlessly
    with programmed
    code, using Qt's signals
    and slots
    mechanism, that lets you
    easily assign behavior to
    graphical elements. All
    properties set in Qt
    Designer can be changed
    dynamically within the
    code.
    Furthermore, features like
    widget promotion and
    custom plugins allow you
    to use your own
    components with Qt
    Designer.
A SIMPLE EXAMPLE
/* HELLOWORLD.CPP */



   1   #include <qapplication.h>
   2   #include <qlabel.h>
   3
   4   int main(int argc, char **argv) {
   5
   6        QApplication myapp(argc, argv);
   7
   8        Qlabel *mylabel = new Qlabel(“Hello World”, 0);
   9        mylabel->resize(100, 200);
  10
  11        myapp.setMainWidget(mylabel);
  12        mylabel->show();
  13        return myapp.exec();
  14   }
LINE-BY-LINE
1 #include <qapplication.h>
2 #include <qlabel.h>
Always #include any Q types referenced in code.

6 QApplication myapp(argc, argv);
Creates an object to manage application-wide resources. Passes
argc and argv because Qt supports a few command line arguments of
its own.

8Qlabel *mylabel = new Qlabel(“Hello World”, 0);
Creates a QLabel widget on the heap. A widgets is any visual
element in a user interface. Widgets can contain other widgets. For
example a window may contain a QMenuBar, QToolBar, QStatusBar,
and other widgets. The 0 parameters says that that the label is a
stand-alone window, is not inside another window.
LINE-BY-LINE
9 mylabel->resize(100, 200);
Invokes the resize() member function.

11 myapp.setMainWidget(mylabel);
Make the label the main application widget. This means that closing the label windows
closes the application.

12 mylabel->show();
Invoke the show() member function to make the label visible. All widgets are created
invisible so that their properties can be manipulated without flickering. For example,
you would show a widget and then change its size and color. You would change the size
and color first, and then show the widget.

13 return myapp.exec();
Passes control of the application to Qt. At this point the application goes into “event-
driven” mode. It will just sit there until the user does something to create an even. This
is the same concept as Word. Word starts and waits for the user to do something.
EVENT HANDLING
   QT's new approach: signals and slots
     A widget sends out various signals
     Object methods can be declared as slots
     Compatible signals and slots can be connected or
      plugged together like a telephone switchboard
      (parameter types must match)
   Strict separation
     This strict separation between UI components and
      program elements lends itself to component-based
      programming
     Goal: separate UI from program logic
SIGNALS AND SLOTS




                    clicked_method()
QMAKE
   The qmake utility is typically invoked with the following three
    commands]

qmake –project
qmake
make (or nmake under Windows)

   Rules:
        Be sure to place code in its own directory.
        qmake scans all subdirectories for dependencies. Do not place archive
         version under a “save” subdirectory.
        If you reorganize your files, like adding a new .h, delete all the .pro and other
         working files, then start over.
DEFINING SIGNALS AND SLOTS
   New C++ syntax for defining signals and
    slots, added to public, private, etc.
    class myClass : public Qobject {
    Q_OBJECT          //required macro, no semicolon
    …
    signals:
       void somethingHappened();
    …
    public slots:
       void slotDoSomething();
    …
    private slots:
       void slotDoSomethingInternal();
    …
    };
EVENTS
   Signals: emit events
     declare as signals, otherwise normal member functions
     You don't implement them. Rather, you send them with
      the (new) keyword emit
     E.g. emit(sliderChanged(5))
   Slots: receive and handle events
       Normal member functions declared as slots
   Connect: must connect signals to slots
       QObject::connect( mymenu, SIGNAL(activated(int)),
        myobject, SLOT(slotDoMenuFunction(int)) );
   moc: meta object compiler (preprocessor) converts
    these new keywords to real C++
WIDGETS
 Base class for all UI widgets
 Properties
       width, height, backgroundColor, font, mouseTracking,
        backgroundPixmap, etc.
   Slots
       repaint, show, hide, move, setGeometry,
        setMainWidget, etc.
   Signals:
       mouseMoveEvent, keyPressEvent, resizeEvent,
        paintEvent, enterEvent, leaveEvent, etc.
QT, A GUI TOOLKIT
   Events processed with signals and slots
    signal generates an event, e.g., button push
    slot processes the event, e.g., pop up a file dialog box
QPushButton * quitB = new QPushButton(“Quit”,...,...);
   connect (quitB, SIGNAL(clicked()), qApp, SLOT(quit());
       qApp is a global variable, of type QApplication
            one QApplication per program defined first in main()
       main returns qApp.exec()
       SIGNAL and SLOT are macros, expanded by a meta-object
   compiler (moc)
       moc generates .cpp files from user-defined Qt subclasses
OTHER FEATURES OF QT
   The Qt Paint Engine
   QPainter is highly optimized and contains several       caching mechanisms
    to speed up drawing. Under X11,         it caches GCs (graphics
    contexts), which often make it     faster than native X11 programs.
   QPainter contains all the functionality one would expect from a professional
    2D graphics library. The coordinate system of a QPainter can be
    transformed using the standard 2D transformations (translate, scale, rotate
    and shear).
   Qt supports Open GL for 3D graphics.
   Qt also contains a set of general purpose classes and a number of
    collection-classes to ease the development of multi-platform applications.
   Qt has platform independent support for the operating system dependent
    functions, such as time/date, files/directories and TCP/IP sockets.
Anupam Kumar Srivastava
Software Engineer
Burl Software Pvt. Ltd
E-mail: anupam.933@gmail.com

More Related Content

What's hot

Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtConvert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
ICS
 
Qt for S60
Qt for S60Qt for S60
Qt for S60
Mark Wilcox
 
Treinamento Qt básico - aula I
Treinamento Qt básico - aula ITreinamento Qt básico - aula I
Treinamento Qt básico - aula I
Marcelo Barros de Almeida
 
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
ICS
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgets
ICS
 
Open gl introduction
Open gl introduction Open gl introduction
Open gl introduction
abigail Dayrit
 
Qt 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
Juha Peltomäki
 
Gtk development-using-glade-3
Gtk development-using-glade-3Gtk development-using-glade-3
Gtk development-using-glade-3
caezsar
 
Building the QML Run-time
Building the QML Run-timeBuilding the QML Run-time
Building the QML Run-time
Johan Thelin
 
Open gl
Open glOpen gl
Open gl
ch samaram
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
Zachary Blair
 
Optimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based ApplicationsOptimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based Applications
account inactive
 
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
ICS
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
Syed Zaid Irshad
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
ICS
 
Treinamento Qt básico - aula III
Treinamento Qt básico - aula IIITreinamento Qt básico - aula III
Treinamento Qt básico - aula III
Marcelo Barros de Almeida
 
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
Jeff Alstadt
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2
NokiaAppForum
 

What's hot (20)

Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with QtConvert Your Legacy OpenGL Code to Modern OpenGL with Qt
Convert Your Legacy OpenGL Code to Modern OpenGL with Qt
 
Qt for S60
Qt for S60Qt for S60
Qt for S60
 
Treinamento Qt básico - aula I
Treinamento Qt básico - aula ITreinamento Qt básico - aula I
Treinamento Qt básico - aula I
 
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 for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgets
 
Open gl introduction
Open gl introduction Open gl introduction
Open gl introduction
 
G T K+ 101
G T K+ 101G T K+ 101
G T K+ 101
 
Qt 5 - C++ and Widgets
Qt 5 - C++ and WidgetsQt 5 - C++ and Widgets
Qt 5 - C++ and Widgets
 
Gtk development-using-glade-3
Gtk development-using-glade-3Gtk development-using-glade-3
Gtk development-using-glade-3
 
Building the QML Run-time
Building the QML Run-timeBuilding the QML Run-time
Building the QML Run-time
 
Open gl
Open glOpen gl
Open gl
 
A Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application FrameworkA Brief Introduction to the Qt Application Framework
A Brief Introduction to the Qt Application Framework
 
Optimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based ApplicationsOptimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based Applications
 
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
 
Programming with OpenGL
Programming with OpenGLProgramming with OpenGL
Programming with OpenGL
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
 
Treinamento Qt básico - aula III
Treinamento Qt básico - aula IIITreinamento Qt básico - aula III
Treinamento Qt básico - aula III
 
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
 
Open gl basics
Open gl basicsOpen gl basics
Open gl basics
 
Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2Petri Niemi Qt Advanced Part 2
Petri Niemi Qt Advanced Part 2
 

Similar to Qt

Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfDeveloping and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
Prabindh Sundareson
 
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
ICS
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)chan20kaur
 
Qt for beginners
Qt for beginnersQt for beginners
Qt for beginners
Sergio Shevchenko
 
Qt Technical Presentation
Qt Technical PresentationQt Technical Presentation
Qt Technical Presentation
Daniel Rocha
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
Janel Heilbrunn
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
ICS
 
The caQtDM powerpoint (ICALEPCS 2013)
The caQtDM powerpoint (ICALEPCS 2013)The caQtDM powerpoint (ICALEPCS 2013)
The caQtDM powerpoint (ICALEPCS 2013)
Robert-Emmanuel Mayssat
 
The caQtDm paper (ICALEPCS 2013)
The caQtDm paper (ICALEPCS 2013)The caQtDm paper (ICALEPCS 2013)
The caQtDm paper (ICALEPCS 2013)
Robert-Emmanuel Mayssat
 
Native Application Development With Qt
Native Application Development With QtNative Application Development With Qt
Native Application Development With Qtrahulnimbalkar
 
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
CybercomChannel
 
IBM Rational Rhapsody and Qt Integration
IBM Rational Rhapsody and Qt IntegrationIBM Rational Rhapsody and Qt Integration
IBM Rational Rhapsody and Qt Integration
gjuljo
 
Intro to gui, cross platform and qt
Intro to gui, cross platform and qtIntro to gui, cross platform and qt
Intro to gui, cross platform and qt
Muhammad Sabry
 
Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017
Johan Thelin
 
Andreas Jakl Software Development on Nokia Deviceswith Qt
Andreas Jakl Software Development on Nokia Deviceswith QtAndreas Jakl Software Development on Nokia Deviceswith Qt
Andreas Jakl Software Development on Nokia Deviceswith Qt
NokiaAppForum
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
Massimiliano Dessì
 
Come costruire una Platform As A Service con Docker, Kubernetes Go e Java
Come costruire una Platform As A Service con Docker, Kubernetes Go e JavaCome costruire una Platform As A Service con Docker, Kubernetes Go e Java
Come costruire una Platform As A Service con Docker, Kubernetes Go e Java
Codemotion
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Daker Fernandes
 

Similar to Qt (20)

Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with XgxperfDeveloping and Benchmarking Qt applications on Hawkboard with Xgxperf
Developing and Benchmarking Qt applications on Hawkboard with Xgxperf
 
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 coin3d soqt
Qt coin3d soqtQt coin3d soqt
Qt coin3d soqt
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)
 
Qt for beginners
Qt for beginnersQt for beginners
Qt for beginners
 
PyQt.pptx
PyQt.pptxPyQt.pptx
PyQt.pptx
 
Qt Technical Presentation
Qt Technical PresentationQt Technical Presentation
Qt Technical Presentation
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
 
Porting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - WebinarPorting Motif Applications to Qt - Webinar
Porting Motif Applications to Qt - Webinar
 
The caQtDM powerpoint (ICALEPCS 2013)
The caQtDM powerpoint (ICALEPCS 2013)The caQtDM powerpoint (ICALEPCS 2013)
The caQtDM powerpoint (ICALEPCS 2013)
 
The caQtDm paper (ICALEPCS 2013)
The caQtDm paper (ICALEPCS 2013)The caQtDm paper (ICALEPCS 2013)
The caQtDm paper (ICALEPCS 2013)
 
Native Application Development With Qt
Native Application Development With QtNative Application Development With Qt
Native Application Development With Qt
 
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
Qt quick at Cybercom Developer Day 2010 by Alexis Menard 7.9.2010
 
IBM Rational Rhapsody and Qt Integration
IBM Rational Rhapsody and Qt IntegrationIBM Rational Rhapsody and Qt Integration
IBM Rational Rhapsody and Qt Integration
 
Intro to gui, cross platform and qt
Intro to gui, cross platform and qtIntro to gui, cross platform and qt
Intro to gui, cross platform and qt
 
Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017Qt Automotive Suite - under the hood // Qt World Summit 2017
Qt Automotive Suite - under the hood // Qt World Summit 2017
 
Andreas Jakl Software Development on Nokia Deviceswith Qt
Andreas Jakl Software Development on Nokia Deviceswith QtAndreas Jakl Software Development on Nokia Deviceswith Qt
Andreas Jakl Software Development on Nokia Deviceswith Qt
 
Dessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloudDessi docker kubernetes paas cloud
Dessi docker kubernetes paas cloud
 
Come costruire una Platform As A Service con Docker, Kubernetes Go e Java
Come costruire una Platform As A Service con Docker, Kubernetes Go e JavaCome costruire una Platform As A Service con Docker, Kubernetes Go e Java
Come costruire una Platform As A Service con Docker, Kubernetes Go e Java
 
Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13Plasmaquick Workshop - FISL 13
Plasmaquick Workshop - FISL 13
 

Recently uploaded

Hollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest galleryHollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest gallery
Zsolt Nemeth
 
Tom Selleck Net Worth: A Comprehensive Analysis
Tom Selleck Net Worth: A Comprehensive AnalysisTom Selleck Net Worth: A Comprehensive Analysis
Tom Selleck Net Worth: A Comprehensive Analysis
greendigital
 
Christina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptxChristina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptx
madeline604788
 
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdfMaximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Xtreame HDTV
 
Meet Crazyjamjam - A TikTok Sensation | Blog Eternal
Meet Crazyjamjam - A TikTok Sensation | Blog EternalMeet Crazyjamjam - A TikTok Sensation | Blog Eternal
Meet Crazyjamjam - A TikTok Sensation | Blog Eternal
Blog Eternal
 
Reimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a SuccessReimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a Success
Mark Murphy Director
 
The Evolution of Animation in Film - Mark Murphy Director
The Evolution of Animation in Film - Mark Murphy DirectorThe Evolution of Animation in Film - Mark Murphy Director
The Evolution of Animation in Film - Mark Murphy Director
Mark Murphy Director
 
Panchayat Season 3 - Official Trailer.pdf
Panchayat Season 3 - Official Trailer.pdfPanchayat Season 3 - Official Trailer.pdf
Panchayat Season 3 - Official Trailer.pdf
Suleman Rana
 
Are the X-Men Marvel or DC An In-Depth Exploration.pdf
Are the X-Men Marvel or DC An In-Depth Exploration.pdfAre the X-Men Marvel or DC An In-Depth Exploration.pdf
Are the X-Men Marvel or DC An In-Depth Exploration.pdf
Xtreame HDTV
 
This Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I MadeThis Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I Made
Aarush Ghate
 
Skeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on ForumSkeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on Forum
Isaac More
 
A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024
Indira Srivatsa
 
From Slave to Scourge: The Existential Choice of Django Unchained. The Philos...
From Slave to Scourge: The Existential Choice of Django Unchained. The Philos...From Slave to Scourge: The Existential Choice of Django Unchained. The Philos...
From Slave to Scourge: The Existential Choice of Django Unchained. The Philos...
Rodney Thomas Jr
 
Scandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.zaScandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.za
Isaac More
 

Recently uploaded (14)

Hollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest galleryHollywood Actress - The 250 hottest gallery
Hollywood Actress - The 250 hottest gallery
 
Tom Selleck Net Worth: A Comprehensive Analysis
Tom Selleck Net Worth: A Comprehensive AnalysisTom Selleck Net Worth: A Comprehensive Analysis
Tom Selleck Net Worth: A Comprehensive Analysis
 
Christina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptxChristina's Baby Shower Game June 2024.pptx
Christina's Baby Shower Game June 2024.pptx
 
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdfMaximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
Maximizing Your Streaming Experience with XCIPTV- Tips for 2024.pdf
 
Meet Crazyjamjam - A TikTok Sensation | Blog Eternal
Meet Crazyjamjam - A TikTok Sensation | Blog EternalMeet Crazyjamjam - A TikTok Sensation | Blog Eternal
Meet Crazyjamjam - A TikTok Sensation | Blog Eternal
 
Reimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a SuccessReimagining Classics - What Makes a Remake a Success
Reimagining Classics - What Makes a Remake a Success
 
The Evolution of Animation in Film - Mark Murphy Director
The Evolution of Animation in Film - Mark Murphy DirectorThe Evolution of Animation in Film - Mark Murphy Director
The Evolution of Animation in Film - Mark Murphy Director
 
Panchayat Season 3 - Official Trailer.pdf
Panchayat Season 3 - Official Trailer.pdfPanchayat Season 3 - Official Trailer.pdf
Panchayat Season 3 - Official Trailer.pdf
 
Are the X-Men Marvel or DC An In-Depth Exploration.pdf
Are the X-Men Marvel or DC An In-Depth Exploration.pdfAre the X-Men Marvel or DC An In-Depth Exploration.pdf
Are the X-Men Marvel or DC An In-Depth Exploration.pdf
 
This Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I MadeThis Is The First All Category Quiz That I Made
This Is The First All Category Quiz That I Made
 
Skeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on ForumSkeem Saam in June 2024 available on Forum
Skeem Saam in June 2024 available on Forum
 
A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024A TO Z INDIA Monthly Magazine - JUNE 2024
A TO Z INDIA Monthly Magazine - JUNE 2024
 
From Slave to Scourge: The Existential Choice of Django Unchained. The Philos...
From Slave to Scourge: The Existential Choice of Django Unchained. The Philos...From Slave to Scourge: The Existential Choice of Django Unchained. The Philos...
From Slave to Scourge: The Existential Choice of Django Unchained. The Philos...
 
Scandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.zaScandal! Teasers June 2024 on etv Forum.co.za
Scandal! Teasers June 2024 on etv Forum.co.za
 

Qt

  • 1. Introduction to Qt The IDE for C++
  • 2. THE QT STORY  Haavard Nord and Eirik Chambe-Eng (the original developers of Qt and the CEO and President, respectively, of Trolltech) began development of "Qt" in 1991, three years before the company was incorporated as Quasar Technologies, then changed the name to Troll Tech and then to Trolltech.  Qt is developed by an open source project, the Qt Project, involving both individual developers as well as developers from Nokia, Digia, and other companies interested in the development of Qt.
  • 3. The Qt toolkit is a multi-platform C++ GUI toolkit (class library) that has been developed over a 6 year period.  The company Troll Tech AS was founded in 1994 to secure future development of Qt.  On May 20, 1995, Qt was made available under commercial and non- commercial GNU licenses. The non-commercial license grants any developer the right to use Qt to develop software for the free software community.  It was ten months before the first commercial license was purchased. The European Space Agency purchased the second.  Around 1997, Qt was chosen as the code basis for the KDE linux desktop environment.  Qt 3.0 was released in 2001 with Windows, Unix, Linux, Embedded Linux, and Mac OS X libraries.
  • 4. WHY CROSS-PLATFORM GUI TOOLKITS  Increases target market.  May provides the same look-and-feel across platform. Reduces training and documentation costs.
  • 5. STATEGIES FOR IMPLEMENTING CROSS-PLATFORM GUIS  API Layering – Mapping one API to many others  Example – wxWindows – Win32 API on top of Motif or Xt API under Unix.  Advantages – easy to write, 100% compatible native look and feel.  Disadvantages –  slower  problems mapping to vastly different API architectures  Lowest common denominator – i.e. no pop-up help anywhere  Objects required a C++ wrapper to work with them in C++
  • 6. QT ASSISTANT  All documentation is available through the trolltech web site.  Qt Assistant is a Qt help browser that runs under Windows.  It has with search and indexing features that make it quicker and easier than the web.
  • 7. `QT DESIGNER  Widgets and forms created with Qt Designer integrated seamlessly with programmed code, using Qt's signals and slots mechanism, that lets you easily assign behavior to graphical elements. All properties set in Qt Designer can be changed dynamically within the code. Furthermore, features like widget promotion and custom plugins allow you to use your own components with Qt Designer.
  • 8. A SIMPLE EXAMPLE /* HELLOWORLD.CPP */ 1 #include <qapplication.h> 2 #include <qlabel.h> 3 4 int main(int argc, char **argv) { 5 6 QApplication myapp(argc, argv); 7 8 Qlabel *mylabel = new Qlabel(“Hello World”, 0); 9 mylabel->resize(100, 200); 10 11 myapp.setMainWidget(mylabel); 12 mylabel->show(); 13 return myapp.exec(); 14 }
  • 9. LINE-BY-LINE 1 #include <qapplication.h> 2 #include <qlabel.h> Always #include any Q types referenced in code. 6 QApplication myapp(argc, argv); Creates an object to manage application-wide resources. Passes argc and argv because Qt supports a few command line arguments of its own. 8Qlabel *mylabel = new Qlabel(“Hello World”, 0); Creates a QLabel widget on the heap. A widgets is any visual element in a user interface. Widgets can contain other widgets. For example a window may contain a QMenuBar, QToolBar, QStatusBar, and other widgets. The 0 parameters says that that the label is a stand-alone window, is not inside another window.
  • 10. LINE-BY-LINE 9 mylabel->resize(100, 200); Invokes the resize() member function. 11 myapp.setMainWidget(mylabel); Make the label the main application widget. This means that closing the label windows closes the application. 12 mylabel->show(); Invoke the show() member function to make the label visible. All widgets are created invisible so that their properties can be manipulated without flickering. For example, you would show a widget and then change its size and color. You would change the size and color first, and then show the widget. 13 return myapp.exec(); Passes control of the application to Qt. At this point the application goes into “event- driven” mode. It will just sit there until the user does something to create an even. This is the same concept as Word. Word starts and waits for the user to do something.
  • 11. EVENT HANDLING  QT's new approach: signals and slots  A widget sends out various signals  Object methods can be declared as slots  Compatible signals and slots can be connected or plugged together like a telephone switchboard (parameter types must match)  Strict separation  This strict separation between UI components and program elements lends itself to component-based programming  Goal: separate UI from program logic
  • 12. SIGNALS AND SLOTS clicked_method()
  • 13. QMAKE  The qmake utility is typically invoked with the following three commands] qmake –project qmake make (or nmake under Windows)  Rules:  Be sure to place code in its own directory.  qmake scans all subdirectories for dependencies. Do not place archive version under a “save” subdirectory.  If you reorganize your files, like adding a new .h, delete all the .pro and other working files, then start over.
  • 14. DEFINING SIGNALS AND SLOTS  New C++ syntax for defining signals and slots, added to public, private, etc. class myClass : public Qobject { Q_OBJECT //required macro, no semicolon … signals: void somethingHappened(); … public slots: void slotDoSomething(); … private slots: void slotDoSomethingInternal(); … };
  • 15. EVENTS  Signals: emit events  declare as signals, otherwise normal member functions  You don't implement them. Rather, you send them with the (new) keyword emit  E.g. emit(sliderChanged(5))  Slots: receive and handle events  Normal member functions declared as slots  Connect: must connect signals to slots  QObject::connect( mymenu, SIGNAL(activated(int)), myobject, SLOT(slotDoMenuFunction(int)) );  moc: meta object compiler (preprocessor) converts these new keywords to real C++
  • 16. WIDGETS  Base class for all UI widgets  Properties  width, height, backgroundColor, font, mouseTracking, backgroundPixmap, etc.  Slots  repaint, show, hide, move, setGeometry, setMainWidget, etc.  Signals:  mouseMoveEvent, keyPressEvent, resizeEvent, paintEvent, enterEvent, leaveEvent, etc.
  • 17. QT, A GUI TOOLKIT  Events processed with signals and slots signal generates an event, e.g., button push  slot processes the event, e.g., pop up a file dialog box QPushButton * quitB = new QPushButton(“Quit”,...,...);  connect (quitB, SIGNAL(clicked()), qApp, SLOT(quit());  qApp is a global variable, of type QApplication  one QApplication per program defined first in main()  main returns qApp.exec()  SIGNAL and SLOT are macros, expanded by a meta-object  compiler (moc)  moc generates .cpp files from user-defined Qt subclasses
  • 18. OTHER FEATURES OF QT  The Qt Paint Engine  QPainter is highly optimized and contains several caching mechanisms to speed up drawing. Under X11, it caches GCs (graphics contexts), which often make it faster than native X11 programs.  QPainter contains all the functionality one would expect from a professional 2D graphics library. The coordinate system of a QPainter can be transformed using the standard 2D transformations (translate, scale, rotate and shear).  Qt supports Open GL for 3D graphics.  Qt also contains a set of general purpose classes and a number of collection-classes to ease the development of multi-platform applications.  Qt has platform independent support for the operating system dependent functions, such as time/date, files/directories and TCP/IP sockets.
  • 19. Anupam Kumar Srivastava Software Engineer Burl Software Pvt. Ltd E-mail: anupam.933@gmail.com