How to rotate a QSlider which is placed on a Qlabel?
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.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
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..
Last edited by Gokulnathvc; 3rd January 2018 at 03:56. Reason: More Details
Here is the code what I have tried.:
Qt 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);To copy to clipboard, switch view to plain text mode
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:
Qt Code:
#include <QtWidgets> int main(int argc, char **argv) { QGraphicsScene scene; QGraphicsProxyWidget *p = scene.addWidget(slider); p->setRotation(20); view.show(); return app.exec(); }To copy to clipboard, switch view to plain text mode
Last edited by ChrisW67; 3rd January 2018 at 07:46.
d_stranz (3rd January 2018)
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.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Bookmarks