How to rotate a QSlider which is placed on a Qlabel?
Printable View
How to rotate a QSlider which is placed on a Qlabel?
One would think that QAbstractSlider::setOrientation() would do it. One also wonders why you would want to put a slider into a label in the first place and not just make a composite widget that contains a layout with the slider and label placed separately in it. QLabel isn't really designed to hold child widgets, despite being derived from QFrame.
I have already placed Horizontal slider holding Custom groove and handle , but I want to rotate the QSlider in a slanting position say about 15 to 20 degrees..
Here is the code what I have tried.:
Code:
ui->horizontalSlider->setParent(ui->graphicsView); QGraphicsProxyWidget *w = scene->addWidget(ui->horizontalSlider); w->setPos(0,45); w->setRotation(12); ui->graphicsView->setScene(scene); ui->graphicsView->show(); ui->graphicsView->rotate(12);
So, you want to arbitrarily rotate a QGraphicsProxyWidget, containing a QSlider, in a QGraphicsScene. This has nothing to do with a QLabel. I hope you can see that your original question was never going to get you a useful answer.
This works as advertised:
Code:
#include <QtWidgets> int main(int argc, char **argv) { QGraphicsScene scene; QGraphicsProxyWidget *p = scene.addWidget(slider); p->setRotation(20); view.show(); return app.exec(); }
Not only that, but it looks like for some reason the OP was using Qt Designer to create a QSlider as part of another widget's UI, and then stealing it to put into the graphics proxy. Clearly is unaware of the concept of creating widgets on the fly in code.