SlideShare a Scribd company logo
1 of 70
. Widgets and Layouts Qt in Education Semana de tecnologia do  Barão de Mauá Instrutor: Marcelo Barros de Almeida [email_address]
© 2010 Nokia Corporation and its Subsidiary(-ies). The enclosed Qt Educational Training Materials are provided under the Creative Commons  Attribution-Non-Commercial-Share Alike 2.5 License Agreement.  The full license text is available here:  http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode . Nokia, Qt and the Nokia and Qt logos are the registered trademarks of Nokia Corporation in Finland and other countries worldwide.
User Interface Components ,[object Object]
46 widgets in Designer
59+ direct descendants from  QWidget QLabel QPushButton QLineEdit QDoubleSpinBox QScrollBar
Widgets in Widgets ,[object Object]
Container classes provide visual structure...
...but also functional (e.g.  QRadioButton ) QGroupBox QTabWidget
Traits of a Widget ,[object Object]
Receives events from input devices
Emits signals for “notable” changes
Are structured in a hierarchy
Can contain other widgets
An Example Dialog ,[object Object]
Why is Elastic Good? ,[object Object]
Lets widgets adapt to translations
Lets widgets adapt to user settings
Layouts ,[object Object]
Layouts and widgets “negotiate” for sizes and positions
Spacer springs can be used to fill voids QGridLayout QVBoxLayout QHBoxLayout
An Example Dialog ,[object Object]
An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerItem( new QSpacerItem(...) ); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerItem( new QSpacerItem(...) ); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerItem( new QSpacerItem(...) ); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerIte m(new QSpacerItem(...)); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerItem(new QSpacerItem(...)); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
An Example Dialog QHBoxLayout *groupLayout = new QHBoxLayout(); QGroupBox *orientationGroup = new QGroupBox(); QVBoxLayout *orientationLayout = new QVBoxLayout(orientationGroup); orientationLayout->addWidget(new QRadioButton("Landscape")); orientationLayout->addWidget(new QRadioButton("Portrait")); groupLayout->addWidget(orientationGroup); QGroupBox *colorGroup = new QGroupBox(); QVBoxLayout *colorLayout = new QVBoxLayout(colorGroup); colorLayout->addWidget(new QRadioButton("Black and White")); colorLayout->addWidget(new QRadioButton("Color")); groupLayout->addWidget(colorGroup); ,[object Object]
An Example Dialog ,[object Object]
Cross Platform Styles ,[object Object]
Cross Platform Issues ,[object Object]
Dialog button ordering
Standard dialogs
Cross Platform Issues ,[object Object]
Dialog button ordering
Standard dialogs Plastique ClearLooks Windows MacOS X
Cross Platform Issues ,[object Object]
Dialog button ordering
Standard dialogs
Cross Platform Issues ,[object Object]
Dialog button ordering
Standard dialogs
Common Widgets ,[object Object]
Designer has a good overview of the widget groups
Common Widgets Buttons ,[object Object]
Signals ,[object Object]
toggled(bool)  – emitted when the check state of the button is changed. ,[object Object],[object Object]
checked  – true when the button is checked.
text – the text of the button.
icon – an icon on the button (can be displayed together with text). QPushButton QCheckBox QRadioButton
Common Widgets Item Widgets ,[object Object]
Adding items ,[object Object]
insertItem(int row, QString)  – inserts an item at the specified row ,[object Object],[object Object],[object Object],[object Object],[object Object],QListWidget QComboBox
Common Widgets Containers ,[object Object]
They can be considered passive (not entirely true)
A plain  QWidget  can be used as a container
Designer: Place widgets in the container and apply a layout to the container
Code: Create a layout for the container and add widgets to the layout QGroupBox *box = new QGroupBox(); QVBoxLayout *layout = new QVBoxLayout(box); layout->addWidget(...); ... QGroupBox QTabWidget QFrame
Common Widgets Input Widgets ,[object Object]
Signals:  ,[object Object]
editingFinished()  - emitted when the widget is left
returnPressed()  - emitted when return is pressed ,[object Object],[object Object]
maxLength  – limits the length of the input
readOnly  – can be set to true to prevent editing (still allows copying) QLineEdit
Common Widgets Input Widgets ,[object Object]
Signals ,[object Object],[object Object],[object Object]
html  – HTML formatted text
readOnly  – can be set to prevent editing ,[object Object]
Signals ,[object Object],[object Object],[object Object],QComboBox QTextEdit
Common Widgets Input Widgets ,[object Object]
There are more for doubles, time and dates

More Related Content

What's hot

Building the QML Run-time
Building the QML Run-timeBuilding the QML Run-time
Building the QML Run-timeJohan Thelin
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...ICS
 
[C++ GUI Programming with Qt4] chap8
[C++ GUI Programming with Qt4] chap8[C++ GUI Programming with Qt4] chap8
[C++ GUI Programming with Qt4] chap8Picker Weng
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)chan20kaur
 
Qt for beginners part 2 widgets
Qt for beginners part 2   widgetsQt for beginners part 2   widgets
Qt for beginners part 2 widgetsICS
 
Observer pattern with Stl, boost and qt
Observer pattern with Stl, boost and qtObserver pattern with Stl, boost and qt
Observer pattern with Stl, boost and qtDaniel Eriksson
 
Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013aleks-f
 
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
 
Learn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentLearn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentMaty Fedak
 
Python-GTK
Python-GTKPython-GTK
Python-GTKYuren Ju
 
6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释zhang shuren
 

What's hot (19)

Building the QML Run-time
Building the QML Run-timeBuilding the QML Run-time
Building the QML Run-time
 
Qt
QtQt
Qt
 
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
OpenGL Fixed Function to Shaders - Porting a fixed function application to “m...
 
[C++ GUI Programming with Qt4] chap8
[C++ GUI Programming with Qt4] chap8[C++ GUI Programming with Qt4] chap8
[C++ GUI Programming with Qt4] chap8
 
Treinamento Qt básico - aula I
Treinamento Qt básico - aula ITreinamento Qt básico - aula I
Treinamento Qt básico - aula I
 
Qt Animation
Qt AnimationQt Animation
Qt Animation
 
Untitled presentation(4)
Untitled presentation(4)Untitled presentation(4)
Untitled presentation(4)
 
Mattbrenner
MattbrennerMattbrenner
Mattbrenner
 
Qt Widget In-Depth
Qt Widget In-DepthQt Widget In-Depth
Qt Widget In-Depth
 
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
Qt for beginnersQt for beginners
Qt for beginners
 
Observer pattern with Stl, boost and qt
Observer pattern with Stl, boost and qtObserver pattern with Stl, boost and qt
Observer pattern with Stl, boost and qt
 
Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013Dynamic C++ ACCU 2013
Dynamic C++ ACCU 2013
 
QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong? QThreads: Are You Using Them Wrong?
QThreads: Are You Using Them Wrong?
 
The Future of Qt Widgets
The Future of Qt WidgetsThe Future of Qt Widgets
The Future of Qt Widgets
 
Learn basics of Clojure/script and Reagent
Learn basics of Clojure/script and ReagentLearn basics of Clojure/script and Reagent
Learn basics of Clojure/script and Reagent
 
Python-GTK
Python-GTKPython-GTK
Python-GTK
 
6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释6.1.1一步一步学repast代码解释
6.1.1一步一步学repast代码解释
 
Hello, QML
Hello, QMLHello, QML
Hello, QML
 

Viewers also liked

Fundamentos de Sistemas Operacionais de Tempo Real - Criando seu próprio esc...
Fundamentos de Sistemas  Operacionais de Tempo Real - Criando seu próprio esc...Fundamentos de Sistemas  Operacionais de Tempo Real - Criando seu próprio esc...
Fundamentos de Sistemas Operacionais de Tempo Real - Criando seu próprio esc...Marcelo Barros de Almeida
 
Optimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based ApplicationsOptimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based Applicationsaccount inactive
 

Viewers also liked (7)

Fundamentos de Sistemas Operacionais de Tempo Real - Criando seu próprio esc...
Fundamentos de Sistemas  Operacionais de Tempo Real - Criando seu próprio esc...Fundamentos de Sistemas  Operacionais de Tempo Real - Criando seu próprio esc...
Fundamentos de Sistemas Operacionais de Tempo Real - Criando seu próprio esc...
 
Agenda em bash e dialog
Agenda em bash e dialogAgenda em bash e dialog
Agenda em bash e dialog
 
Optimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based ApplicationsOptimizing Performance in Qt-Based Applications
Optimizing Performance in Qt-Based Applications
 
Lista de exercícios em Bash (resolvida)
Lista de exercícios em Bash (resolvida) Lista de exercícios em Bash (resolvida)
Lista de exercícios em Bash (resolvida)
 
Administração de Redes Linux - II
Administração de Redes Linux - IIAdministração de Redes Linux - II
Administração de Redes Linux - II
 
Administração de Redes Linux - I
Administração de Redes Linux - IAdministração de Redes Linux - I
Administração de Redes Linux - I
 
Administração de Redes Linux - III
Administração de Redes Linux - IIIAdministração de Redes Linux - III
Administração de Redes Linux - III
 

Similar to Treinamento Qt básico - aula III

Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWTbackdoor
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01JONDHLEPOLY
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01Ankit Dubey
 
4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15Rajes Wari
 
Unit-1 awt advanced java programming
Unit-1 awt advanced java programmingUnit-1 awt advanced java programming
Unit-1 awt advanced java programmingAmol Gaikwad
 
[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6Picker Weng
 
Unit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptxUnit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptxssuser10ef65
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Marlon Luz
 
Meet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIMeet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIICS
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training Moutasm Tamimi
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Javasuraj pandey
 

Similar to Treinamento Qt básico - aula III (20)

Windows Programming with AWT
Windows Programming with AWTWindows Programming with AWT
Windows Programming with AWT
 
Gui
GuiGui
Gui
 
Unit 5 java-awt (1)
Unit 5 java-awt (1)Unit 5 java-awt (1)
Unit 5 java-awt (1)
 
Awt
AwtAwt
Awt
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
tL19 awt
tL19 awttL19 awt
tL19 awt
 
Ajp notes-chapter-01
Ajp notes-chapter-01Ajp notes-chapter-01
Ajp notes-chapter-01
 
4.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.154.7.14&17.7.14&23.6.15&10.9.15
4.7.14&17.7.14&23.6.15&10.9.15
 
Unit-1 awt advanced java programming
Unit-1 awt advanced java programmingUnit-1 awt advanced java programming
Unit-1 awt advanced java programming
 
[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6[C++ GUI Programming with Qt4] chap6
[C++ GUI Programming with Qt4] chap6
 
13457272.ppt
13457272.ppt13457272.ppt
13457272.ppt
 
Unit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptxUnit – I-AWT-updated.pptx
Unit – I-AWT-updated.pptx
 
Gui programming
Gui programmingGui programming
Gui programming
 
Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2Nokia Asha App Development - Part 2
Nokia Asha App Development - Part 2
 
Meet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UIMeet the Widgets: Another Way to Implement UI
Meet the Widgets: Another Way to Implement UI
 
Windows form application - C# Training
Windows form application - C# Training Windows form application - C# Training
Windows form application - C# Training
 
GWT Widgets
GWT WidgetsGWT Widgets
GWT Widgets
 
Awt and swing in java
Awt and swing in javaAwt and swing in java
Awt and swing in java
 
28 awt
28 awt28 awt
28 awt
 
Basic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in JavaBasic of Abstract Window Toolkit(AWT) in Java
Basic of Abstract Window Toolkit(AWT) in Java
 

More from Marcelo Barros de Almeida

[9/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[9/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[9/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[9/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...Marcelo Barros de Almeida
 
[8/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[8/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[8/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[8/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...Marcelo Barros de Almeida
 
[7/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[7/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[7/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[7/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...Marcelo Barros de Almeida
 
[6/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[6/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[6/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[6/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...Marcelo Barros de Almeida
 
[5/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[5/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[5/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[5/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...Marcelo Barros de Almeida
 
[4/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[4/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[4/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[4/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...Marcelo Barros de Almeida
 
[3/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[3/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[3/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[3/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...Marcelo Barros de Almeida
 
[2/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[2/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[2/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[2/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...Marcelo Barros de Almeida
 
Projeto de Hardware com Microcontroladores STM32
Projeto de Hardware com Microcontroladores STM32Projeto de Hardware com Microcontroladores STM32
Projeto de Hardware com Microcontroladores STM32Marcelo Barros de Almeida
 
Criando Placas Eletrônicas com KiCAD (Marcelo Barros)
Criando Placas Eletrônicas com KiCAD (Marcelo Barros)Criando Placas Eletrônicas com KiCAD (Marcelo Barros)
Criando Placas Eletrônicas com KiCAD (Marcelo Barros)Marcelo Barros de Almeida
 
Fundamentos de Sistemas Operacionais de Tempo Real - Criando seu próprio esc...
Fundamentos de Sistemas  Operacionais de Tempo Real - Criando seu próprio esc...Fundamentos de Sistemas  Operacionais de Tempo Real - Criando seu próprio esc...
Fundamentos de Sistemas Operacionais de Tempo Real - Criando seu próprio esc...Marcelo Barros de Almeida
 
Python para desenvolvedores - material apoio (parte I)
Python para desenvolvedores - material apoio (parte I)Python para desenvolvedores - material apoio (parte I)
Python para desenvolvedores - material apoio (parte I)Marcelo Barros de Almeida
 
Sistemas embarcados: motivação e primeiros passos
Sistemas embarcados: motivação e primeiros passosSistemas embarcados: motivação e primeiros passos
Sistemas embarcados: motivação e primeiros passosMarcelo Barros de Almeida
 

More from Marcelo Barros de Almeida (14)

[9/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[9/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[9/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[9/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
 
[8/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[8/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[8/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[8/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
 
[7/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[7/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[7/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[7/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
 
[6/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[6/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[6/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[6/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
 
[5/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[5/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[5/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[5/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
 
[4/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[4/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[4/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[4/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
 
[3/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[3/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[3/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[3/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
 
[2/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[2/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...[2/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
[2/9] Sistemas embarcados de alto desempenho para tratamento e processamento ...
 
Projeto de Hardware com Microcontroladores STM32
Projeto de Hardware com Microcontroladores STM32Projeto de Hardware com Microcontroladores STM32
Projeto de Hardware com Microcontroladores STM32
 
Criando Placas Eletrônicas com KiCAD (Marcelo Barros)
Criando Placas Eletrônicas com KiCAD (Marcelo Barros)Criando Placas Eletrônicas com KiCAD (Marcelo Barros)
Criando Placas Eletrônicas com KiCAD (Marcelo Barros)
 
Fundamentos de Sistemas Operacionais de Tempo Real - Criando seu próprio esc...
Fundamentos de Sistemas  Operacionais de Tempo Real - Criando seu próprio esc...Fundamentos de Sistemas  Operacionais de Tempo Real - Criando seu próprio esc...
Fundamentos de Sistemas Operacionais de Tempo Real - Criando seu próprio esc...
 
Python para desenvolvedores - material apoio (parte I)
Python para desenvolvedores - material apoio (parte I)Python para desenvolvedores - material apoio (parte I)
Python para desenvolvedores - material apoio (parte I)
 
Tutorial sobre iptables
Tutorial sobre iptablesTutorial sobre iptables
Tutorial sobre iptables
 
Sistemas embarcados: motivação e primeiros passos
Sistemas embarcados: motivação e primeiros passosSistemas embarcados: motivação e primeiros passos
Sistemas embarcados: motivação e primeiros passos
 

Recently uploaded

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...gurkirankumar98700
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitecturePixlogix Infotech
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 

Recently uploaded (20)

Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service 🍸 8923113531 🎰 Avail...
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
Understanding the Laravel MVC Architecture
Understanding the Laravel MVC ArchitectureUnderstanding the Laravel MVC Architecture
Understanding the Laravel MVC Architecture
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 

Treinamento Qt básico - aula III

  • 1. . Widgets and Layouts Qt in Education Semana de tecnologia do Barão de Mauá Instrutor: Marcelo Barros de Almeida [email_address]
  • 2. © 2010 Nokia Corporation and its Subsidiary(-ies). The enclosed Qt Educational Training Materials are provided under the Creative Commons Attribution-Non-Commercial-Share Alike 2.5 License Agreement. The full license text is available here: http://creativecommons.org/licenses/by-nc-sa/2.5/legalcode . Nokia, Qt and the Nokia and Qt logos are the registered trademarks of Nokia Corporation in Finland and other countries worldwide.
  • 3.
  • 4. 46 widgets in Designer
  • 5. 59+ direct descendants from QWidget QLabel QPushButton QLineEdit QDoubleSpinBox QScrollBar
  • 6.
  • 7. Container classes provide visual structure...
  • 8. ...but also functional (e.g. QRadioButton ) QGroupBox QTabWidget
  • 9.
  • 10. Receives events from input devices
  • 11. Emits signals for “notable” changes
  • 12. Are structured in a hierarchy
  • 13. Can contain other widgets
  • 14.
  • 15.
  • 16. Lets widgets adapt to translations
  • 17. Lets widgets adapt to user settings
  • 18.
  • 19. Layouts and widgets “negotiate” for sizes and positions
  • 20. Spacer springs can be used to fill voids QGridLayout QVBoxLayout QHBoxLayout
  • 21.
  • 22. An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerItem( new QSpacerItem(...) ); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
  • 23. An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerItem( new QSpacerItem(...) ); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
  • 24. An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerItem( new QSpacerItem(...) ); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
  • 25. An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerIte m(new QSpacerItem(...)); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
  • 26. An Example Dialog QVBoxLayout *outerLayout = new QVBoxLayout(this); QHBoxLayout *topLayout = new QHBoxLayout(); topLayout->addWidget(new QLabel("Printer:")); topLayout->addWidget(c=new QComboBox()); outerLayout->addLayout(topLayout); QHBoxLayout *groupLayout = new QHBoxLayout(); ... outerLayout->addLayout(groupLayout); outerLayout->addSpacerItem(new QSpacerItem(...)); QHBoxLayout *buttonLayout = new QHBoxLayout(); buttonLayout->addSpacerItem(new QSpacerItem(...)); buttonLayout->addWidget(new QPushButton("Print")); buttonLayout->addWidget(new QPushButton("Cancel")); outerLayout->addLayout(buttonLayout);
  • 27.
  • 28.
  • 29.
  • 30.
  • 33.
  • 35. Standard dialogs Plastique ClearLooks Windows MacOS X
  • 36.
  • 39.
  • 42.
  • 43. Designer has a good overview of the widget groups
  • 44.
  • 45.
  • 46.
  • 47. checked – true when the button is checked.
  • 48. text – the text of the button.
  • 49. icon – an icon on the button (can be displayed together with text). QPushButton QCheckBox QRadioButton
  • 50.
  • 51.
  • 52.
  • 53.
  • 54. They can be considered passive (not entirely true)
  • 55. A plain QWidget can be used as a container
  • 56. Designer: Place widgets in the container and apply a layout to the container
  • 57. Code: Create a layout for the container and add widgets to the layout QGroupBox *box = new QGroupBox(); QVBoxLayout *layout = new QVBoxLayout(box); layout->addWidget(...); ... QGroupBox QTabWidget QFrame
  • 58.
  • 59.
  • 60. editingFinished() - emitted when the widget is left
  • 61.
  • 62. maxLength – limits the length of the input
  • 63. readOnly – can be set to true to prevent editing (still allows copying) QLineEdit
  • 64.
  • 65.
  • 66. html – HTML formatted text
  • 67.
  • 68.
  • 69.
  • 70. There are more for doubles, time and dates
  • 71.
  • 72. maximum – the maximum value
  • 73. minimum – the minimum value QSlider QScrollBar QDial QSpinBox
  • 74.
  • 75.
  • 76.
  • 77.
  • 78.
  • 79. enabled – enable or disable user interaction
  • 80. visible – shown or not (alter with show and hide)
  • 81. These properties affect child widgets as well. For instance, enable or disable a container widget.
  • 82.
  • 83.
  • 84.
  • 86.
  • 87.
  • 88. Minimum – the hint specifies the smallest possible size
  • 89. Maximum – the hint specifies the largest possible size
  • 90. Preferred – the hint specifies preferred, but not required
  • 91. Expanding – as preferred, but wants to grow
  • 92. MinimumExpanding – as minimum, but wants to grow
  • 93. Ignored – the size hint is ignored, widget gets as much space as possible
  • 94.
  • 95. Minimum – can grow
  • 96. Maximum – can shrink
  • 97. Preferred – can grow , can shrink
  • 98. Expanding – can grow , can shrink , wants to grow
  • 99. MinimumExpanding – can grow , wants to grow
  • 100. Ignored – the size hint is ignored, can grow , can shrink
  • 101.
  • 102. One preferred, one expanding
  • 103. Two expanding next to each other
  • 104. Not enough widget to fill the space (fixed)
  • 105.
  • 106. maximumSize – largest possible size
  • 107. minimumSize – smallest possible size ui->pushButton->setMinimumSize(100, 150); ui->pushButton->setMaximumHeight(250);
  • 108.
  • 109. A visual editor for forms
  • 113. Introducing Designer includes compiles links compiles mocs
  • 114. Introducing Designer uic includes compiles links compiles mocs
  • 115. Using the Code #ifndef WIDGET_H #define WIDGET_H #include <QWidget> namespace Ui { class Widget; } class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(); private: Ui::Widget *ui; }; #endif // WIDGET_H Forward declaration of the Ui::Widget class A Ui::Widget pointer, ui , refers to all widgets Basically a standard QWidget derived class
  • 116. Using the Code #include &quot;widget.h&quot; #include &quot;ui_widget.h&quot; Widget::Widget(QWidget *parent) : QWidget(parent), ui(new Ui::Widget) { ui->setupUi(this); } Widget::~Widget() { delete ui; } Instanciates the Ui::Widget class as ui Deletes the ui object Calls setupUi , creating all the widgets as children to the given parent ( this ).
  • 117.
  • 118. Apply layouts from the inside out, add spacers as needed
  • 120.
  • 121. Using Designer drag-and-drop Place widgets roughly
  • 122. Using Designer Apply layouts from the inside out, add spacers as needed 1 . Select each group box, 2 . apply a vertical box layout
  • 123. Using Designer Apply layouts from the inside out, add spacers as needed 1 . Select the label (click), 2 . Select the combobox (Ctrl+click)
  • 124. Using Designer Apply layouts from the inside out, add spacers as needed 1 . Apply a horizontal box layout
  • 125. Using Designer Apply layouts from the inside out, add spacers as needed 1 . Select both group boxes and lay them out, 2 . add a horizontal spacer, 3 . place the buttons and spacer in a layout
  • 126. Using Designer Apply layouts from the inside out, add spacers as needed 1 . Add a vertical spacer, 2 . select the form itself, 3 . apply a vertical box layout
  • 127. Using Designer Make connections (between widgets) 1 . Switch to signals and slot editing mode, 2 . drag from one widget to another, 3 . pick the signal and slot, 4 . see the result in the connections' dock
  • 128. Using Designer Make connections (to your code) 1 . Use the widget editing mode, 2 . right click on a widget and pick Go to slot... 3 . pick the signal to connect to your code
  • 129.
  • 130.
  • 131. QDialog – a dialog, usually expecting a result such as Ok, Cancel, etc
  • 132.
  • 133.
  • 134. Widgets without parent are automatically windows
  • 135. Widgets with parent have to pass the Qt::Window flag to the QWidget constructor
  • 136.
  • 137. WindowModal – the parent window is blocked
  • 138. ApplicationModal – all other windows are blocked
  • 139.
  • 140.
  • 141.
  • 144. etc
  • 145.
  • 146. Inherited from QDialog
  • 147.
  • 148. Buttons for accepting or rejecting
  • 149. The Programming Interface class SearchDialog : public QDialog { Q_OBJECT public: explicit SearchDialog(const QString &initialText, bool isBackward, QWidget *parent = 0); bool isBackward() const; const QString &searchText() const; private: Ui::SearchDialog *ui; };
  • 150. The Implementation SearchDialog::SearchDialog(const QString &initialText, bool isBackward, QWidget *parent) : QDialog(parent), ui(new Ui::SearchDialog) { ui->setupUi(this); ui->searchText->setText(initialText); if(isBackward) ui->directionBackward->setChecked(true); else ui->directionForward->setChecked(true); } bool SearchDialog::isBackward() const { return ui->directionBackward->isChecked(); } const QString &SearchDialog::searchText() const { return ui->searchText->text(); }
  • 151.
  • 152.
  • 155. Docks
  • 157.
  • 158. A QAction object can represent all these access ways – and hold tool tips, statusbar hints, etc too Ctrl+S Action
  • 159.
  • 160.
  • 161. icon – icon to be used everywhere
  • 162. shortcut – shortcut
  • 163. checkable / checked – if the action is checkable and the current check status
  • 164. toolTip / statusTip – tips text for tool tips (hover and wait) and status bar tips (hover, no wait)
  • 165.
  • 166.
  • 167. In Designer, simply drag and drop each action into place on a tool bar or menu myMenu->addAction(action); myToolBar->addAction(action);
  • 168.
  • 169. QMainWindow::addDockWidget adds the docks to the window
  • 170. Dock widgets void MainWindow::createDock() { QDockWidget *dock = new QDockWidget (&quot;Dock&quot;, this); dock-> setFeatures (QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetFloatable); dock-> setAllowedAreas (Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); dock-> setWidget (actualWidget); ... addDockWidget (Qt::RightDockWidgetArea, dock); }
  • 171.
  • 172. No need to try to determine the path for the icons for each specific install type
  • 173. All fits neatly into the build system
  • 174. ...
  • 175. You can add anything into resources, not only icons
  • 176.
  • 177. Prefix path and filenames with : to use a resource
  • 178. Or simply pick an icon from the list in Designer QPixmap pm(&quot; : / images/logo.png&quot;);
  • 179.
  • 180. Style sheets are inspired from CSS
  • 181. They can be used for highlighting and for various small alternations
  • 182. As well as a total overhaul of the entire user interface
  • 183.
  • 184.