QT IS NOT QuickTime,
(Learning is thou)
Qt is Object Oriented C++ GUI Toolkit.
Loads if pre-made widgets that make up/found in a modern desktop
application.
Loads of utility classes to get your job done fast.
Runs on embedded systems,
OSS Wrappers for various programming languages (Python, Ruby, Java,
etc)
Dual licensing (Commercial Developers Pay, Free Software/OSS
developers don’t. Hail RMS)
Qt Style Sheets the Makeup Box
What is stylesheets?
Text based specification describing how widgets are presented on screen.
Every widget has a set of look and feel attributes. With Style sheets one can
specify /change the attribute values, thus changing the appearance.
QPushButton { background-color: red }
QPushButton { background-color: red }
selector declaration
Style sheet can be applied on a single widget, or all the widgets that make
up the application. In the latter case it becomes Cascading Style Sheets.
qapp->setStyleSheet(style);
Widgets from Style sheet perspective
States of widgets and style sheet
(Hover, Pressed, Released)
Sub controls of the widgets
(Items/Controls that make up the widget)
Sub controls of the widgets
• The QScrollBar can be styled using its subcontrols like handle, add-line, sub-line, and so on. Note that if one property or
sub-control is customized, all the other properties or sub-controls must be customized as well.
• QScrollBar:horizontal { border: 2px solid grey; background: #32CC99; height: 15px; margin: 0px 20px 0 20px; }
• QScrollBar::handle:horizontal { background: white; min-width: 20px; }
• QScrollBar::add-line:horizontal { border: 2px solid grey; background: #32CC99; width: 20px; subcontrol-position: right;
subcontrol-origin: margin; }
• QScrollBar::sub-line:horizontal { border: 2px solid grey; background: #32CC99; width: 20px; subcontrol-position: left;
subcontrol-origin: margin; }
Where to learn more?
• Qt Docs
• Qt Demo
• http://code.google.com (Check other’s code
and see how they make their UI look cool.)
Making your own widgets
(Beauty is skin deep )
Paint shall we
Canvas
What matters while painting ?
Basic colors, create
new colors.
width, color.
Canvas
Length, height, color
Color, size.
Graphics View Framework
• Graphics View provides a surface for managing and
interacting with a large number of custom-made 2D
graphical items, and a view widget for visualizing the
items, with support for zooming and rotation.
• Interactive plane,
• Model View Programming,
• What’s QGraphicsView,
QGraphicsScene,
QGraphicsItem,
Qblah and blah?
Graphics View Framework
• Graphics View provides a surface for managing
and interacting with a large number of custom-
made 2D graphical items, and a view widget for
visualizing the items, with support for zooming
and rotation.
• What’s QGraphicsView,
QGraphicsScene,
QGraphicsItem,
Qblah and blah?
Model View Programming,
• Model – The Data Container
• View – The Data Visualizer
• Item – The Atomic Data
Model View Programming,
• Model – QGraphicsScene
• View – QGraphicsWidget
• Item – QGraphicsItem
QGraphicsItem
• Qt provides a set of standard graphics items for the most
common shapes. These are:
• QGraphicsEllipseItem provides an ellipse item
• QGraphicsLineItem provides a line item
• QGraphicsPathItem provides an arbitrary path item
• QGraphicsPixmapItem provides a pixmap item
• QGraphicsPolygonItem provides a polygon item
• QGraphicsRectItem provides a rectangular item
• QGraphicsSimpleTextItem provides a simple text label item
• QGraphicsTextItem provides an advanced text browser
item
• Derive and create your own mouse item.
QGraphicsScene
The QGraphicsScene class provides a surface for
managing a large number of 2D graphical items.
QGraphicsScene aScene(NULL);
QGraphicsTextItem aTextItem(“ilug-bom,
NULL”);
aScene.addItem(aTextItem);
QGraphicsView
QGraphicsView provides the view widget, which
visualizes the contents of a scene.
Ilug-bom
The Grapshics View Coordinate System
The scene represents the base coordinate system for all its items. Scene is infinite.
Compute length and width to accommodate all item’s location
View coordinates are the coordinates of the widget. Each unit in view
coordinates corresponds to one pixel.
Items live in their own local coordinate system.
Tough things made simple
Z ooming and rotating
scale(1.2, 1.2);
Painting
QPixmap pixmap;
QPainter painter(&pixmap);
painter.setRenderHint(QPainter::Antialiasing);
scene.render(&painter); painter.end();
pixmap.save(\"scene.png\");
Drag and Drop
void CustomItem::mousePressEvent(QGraphicsSceneMouseEvent *event)
{
QMimeData *data = new QMimeData;
data->setColor(Qt::green);
QDrag *drag = new QDrag(event->widget());
drag->setMimeData(data); drag->start();
}
0 comments
Post a comment