qgraphicsview

QGraphicsView scrolling and image scaling/cropping

I would like to have a background image in my QGraphicsView that is always scaled (and cropped if necessary) to the size of the viewport, without scrollbars and without scrolling with the keyboard and mouse. The example below is what I am doing to scale and crop an image in the viewport, but I am using random values for the cropping that...

QT's QGraphicsview clickable icon on screen

I'm working on a project with QT and am trying to draw icons from a database. I have auxiliary information in the table that I would like to display if the user chooses to see it (i.e. the x,y of the icon and some other options from database). I am debating on would it be better to go through and just redraw all the icons with this in...

Qt Graphics Scene mouse event propagation

hello i'm learning qt and i'm doing the folowing to add some widgets to a graphics scene void MainWindow::addWidgets(QList<QWidget *> &list, int code) { if(code == CODE_INFO) { QWidget *layoutWidget = new QWidget(); QVBoxLayout *layout = new QVBoxLayout(); foreach(QWidget *w, list) { ...

Custom QGraphicsItems not compiling and gives "object is private" error

Hi, I am trying to create a Custom QGraphicsItem button as shown by Fred here. The code which he posted can be found here. The problem is when I try and compile the code I get the following two errors: /usr/include/qt4/QtGui/qgraphicsitem.h ‘QGraphicsItem::QGraphicsItem(const QGraphicsItem&)’ is private /usr/include/qt4/QtCore/qobjec...

Qt - invalid conversion to child class

I'm drawing polygons using the Graphics View framework. I added a polygon to the scene with this: QGraphicsPolygonItem *poly = scene->addPolygon(QPolygonF(vector_of_QPointF)); poly->setPos(some_point); But I need to implement some custom behaviour like selection, mouse over indicator, and other similar stuff on the graphics item. So I...

Qt - drag and drop with graphics view framework

I'm trying to make a simple draggable item using the graphics framework. Here's the code for what I did so far: Widget class: class Widget : public QWidget { Q_OBJECT public: Widget(QWidget *parent = 0); ~Widget(); }; Widget::Widget(QWidget *parent) : QWidget(parent) { DragScene *scene = new DragScene(); Drag...

Subclassing QGraphicsItemGroup

Hi everyone I have system that has classes derived from QGraphicsWidget. I manage derived class objects in layouts on QGraphicsScene. Now I need a compound item that contain two or more QGraphicsWidget in it and also I need to put that item inside my layout. So I choose QGraphicsItemGroup and write I class like this. class CompositeIte...

RubyQT QGraphicsview scale images to fit window

I'm trying to make an image scale inside of a QGraphicsView and having zero success. I did find this C++ question with what seemed to be the same problem:http://stackoverflow.com/questions/2489754/qgraphicsview-scrolling-and-image-scaling-cropping I borrowed the approach of overriding the drawback/foreground. However when I run the scr...

Container item implementation

Hi, I am working in Train Traffic Controller software project. My responsibility in this project is to develop the visual railroad GUI. We are implementing the project with Qt. By now I am using QGraphicsLinearLayout to hold my items. I am using the layout because I do not want to calculate coordinates of each item. So far I wrote item...

Get updated size of QGraphicsView

Hi, In my Qt Application I am dynamically creating QGraphicsView(s) and adding them inside a QGridLayout. When I add first view inside grid, the view covers all the available space inside grid. Then I add second view and there are now two equally sized views inside grid. Then I add third view and there are now three equally sized views ...

General advice about scaling on QGraphicsView/QGraphicsScene

Hi, In my project I am using QGraphicsView/QGraphicsScene stuff. On my scene there will be regions that contains 2D graphics. Region count will be limited(Lets say 20) Users can choose to display one or more regions. If user choose to display one region I am going to show one region on scene If user choose to display n regions I am goin...

QGraphicsView ensureVisible() and centerOn()

Hi, I am going to do pan/scale stuff on QGraphicsView. So I read the documentation of QGraphicsView and see some utility functions like ensureVisible() and centerOn(). I think I understand what the documentation says but I can' t manage to write a working example. Could you please write/suggest me an example code to understand the issue....

QGraphicsItem doesn't receive mouse hover events

I have a class derived from QGraphicsView, which contains QGraphicsItem-derived elements. I want these elements to change color whenever the mouse cursor hovers over them, so I implemented hoverEnterEvent (and hoverLeaveEvent): void MyGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent* event) { update (boundingRect()); } Howe...

Drawing widgets (such as buttons) over QGraphicsView

How do I draw interactive widgets such as QButtons and Line Edits over a QGraphicsView? For ex, I have selected a region over an image in an image editing app which displays an image with QGraphicsView, and I want to annotate this region with a name. So I want to have a Line edit and two buttons (Cross and Tick) below this rectangular ...

Lots of pointer casts in QGraphicsView framework and performance

Since most of the convenience functions of QGraphicsScene and QGraphicsItem (such as items(), collidingItems(), childItems() etc.) return a QList you're forced to do lots of qgraphicsitem_cast or static_cast and QGraphicsItem::Type() checks to get hold of the actual items when you have lots of different type of items in the scene. I thou...

Embedded QGraphicsView do not hide after Dialog closes

I call a QDialog in to modes, showNormal and showFullscreen. In normal mode all works fine. With a Keyevent the Dialog closes as expected. In Fullscreen, after a keyevent the Dialog closes, but the QGraphicsView will stay on top. All things i've tried (like closing/updating the view) failed. the View sta on top. view = new QGraphicsView...

Custom QAbstractGraphicsShapeItem very slow in Qt Jambi

I try to implement an own QAbstractGraphicsShapeItem in Qt Jambi (4.5) but as soon as I implement a custom class (rather than use e.g. QGraphicsEllipseItem) the rendering speed drops by about on order of magnitude. If looked in the original Code of QGraphicsEllipseItem and it seems to do basicly the same. class Circle extends QAbstractG...

Events with QGraphicsItemGroup

In my application I want to use QGraphicsItemGroup for grouping items into one item. I played with it a little and not sure using it because when I want to catch events, events are merged together but I want to handle specific event with specific child. How can I achieve this? ...

How can let Qt Graphics View Framework support custom layers

Qt's graphics view frameworks is very powerful, but I have not found a way to support custom layers. In Qt, there is a QGraphicsScene::ItemLayer,but QGraphicsScene renders all items are in this layer. I want manage the items with several layers, Just like Illustrator and CorelDraw. all the item only in the current layer will receive the...

The best way to use Video with QGraphicsScene

I am currently using Phonon VideoWidgets inside of a QGraphicsScene using a QGraphicsProxyWidget. I have my viewport set to a QGLWidget. However, it causes me big issues when I try to apply some transforms to the video such as a rotation that isn't evenly divisible by 90 degrees since then it slows my program down a lot. After reading...