Go back to Richel Bilderbeek's homepage.
Go back to Richel Bilderbeek's C++ page.



Qt example 31: moveable thin lines is a Qt example to create some lines that are moveable. Note
that because the lines are one pixel thin, it is difficult to really move them!
QtExample32 solves this problem.
Technical facts
Application type(s)
Operating system(s) or programming environment(s)
IDE(s):
Project type:
C++ standard:
Compiler(s):
Libraries used:
Qt: version 5.4.1 (32 bit)
STL: GNU ISO C++ Library, version 4.9.2
Qt project file: ./CppQtExample31/CppQtExample31.pro
./CppQtExample31/dialog.h
./CppQtExample31/dialog.cpp
./CppQtExample31/qtarrowitem.h
./CppQtExample31/qtarrowitem.cpp
#include <iostream>
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Weffc++"
#pragma GCC diagnostic ignored "-Wunused-local-typedefs"
#include <QCursor>
#include <QFont>
#include <QGraphicsSceneMouseEvent>
#include <QPainter>
#include "qtarrowitem.h"
#pragma GCC diagnostic pop
QtArrowItem::QtArrowItem(
const double x1,
const double y1,
const bool tail,
const double x2,
const double y2,
const bool head,
QGraphicsItem *parent)
: QGraphicsLineItem(x1,y1,x2,y2,parent),
m_head(head),
m_tail(tail)
{
this->setFlags(QGraphicsItem::ItemIsMovable);
}
QRectF QtArrowItem::boundingRect() const
{
return QRectF(this->line().p1(),this->line().p2());
}
void QtArrowItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *)
{
painter->drawLine(this->line());
}
|
./CppQtExample31/qtarrowswidget.h
./CppQtExample31/qtarrowswidget.cpp
./CppQtExample31/qtmain.cpp
Go back to Richel Bilderbeek's C++ page.
Go back to Richel Bilderbeek's homepage.

This page has been created by the tool CodeToHtml