PDA

View Full Version : Rotating Items



PauloF91
26th May 2013, 23:16
I’m really new at C++, and this Qt thing. I’m trying to create a GUI Application, to plot some graphics.
I’m aware of QGraphicsView, and I’ve made my own graphic (with grids and stuff), it’s pretty much ready to go.

But there’s a problem, I want to rotate my Y-axis label, like we’re used to see them. I’ve used QGraphicsView::rotate, but it’s kinda ugly, and not really professional. I wanted to know if there’s a better way to do this (maybe with QTransform, I didn’t have the time to check yet). All I want is to get a label displayed with a -90º rotation.

I’m sorry if there’s already a topic about this, if you could link it to me, would be awesome. This is kinda of an emergency.

Just one more thing:
If I want to use QwtPlot and QwtPlotCurve, how do I put it in a layout?

Thanks in advance.

PF91

rawfool
27th May 2013, 06:04
If I want to use QwtPlot and QwtPlotCurve, how do I put it in a layout?Draw the QwtPlot and QwtPlotCurve on a widget and place the widget on the layout.

ChrisW67
27th May 2013, 06:37
If I want to use QwtPlot and QwtPlotCurve, how do I put it in a layout?
Exactly the same way you put any other QWidget in a layout. Perhaps I don't understand the problem.

wysota
27th May 2013, 07:46
I’ve used QGraphicsView::rotate, but it’s kinda ugly, and not really professional.

What exactly is "ugly" and how did you implement your item?

PauloF91
27th May 2013, 16:06
Draw the QwtPlot and QwtPlotCurve on a widget and place the widget on the layout.


Exactly the same way you put any other QWidget in a layout. Perhaps I don't understand the problem.


Yes, that's what I'm saying, but I tried it as a widget and didn't work out. I'll check it again. Thanks.


What exactly is "ugly" and how did you implement your item?

I created another QGraphicsView with a label on it, and rotated it -90º. It's ok, but I'd like something diferent.
I'll try QwtPlot again.

I appreciate the effort.

PF91

PS: I tried to draw QwtPlot straight in a layout as a widget, that's what went wrong I guess. How do I draw it in a widget? Im trying to figure out..

wysota
27th May 2013, 18:15
I created another QGraphicsView with a label on it, and rotated it -90º. It's ok, but I'd like something diferent.

You should have subclassed QGraphicsItem and reimplemented its paint() routine.

ChrisW67
27th May 2013, 22:23
PS: I tried to draw QwtPlot straight in a layout as a widget, that's what went wrong I guess. How do I draw it in a widget? Im trying to figure out..
QwtPlot is a QWidget. You put it into layout exactly the same way you put any QWidget in a layout... and it behaves as it should. Repeatedly saying "it doesn't work" neither describes the problem nor aids in its solution.

PauloF91
28th May 2013, 00:46
That's the problem then... it just gives me this message: The program has unexpectedly finished.
Somehow I failed installing qwt-6.0, but was still able to use its classes. Thats something else I have to worry about.

Thanks for everything, should be enough.

PF91