Results 1 to 6 of 6

Thread: How to rotate a QSlider?

  1. #1
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default How to rotate a QSlider?

    How to rotate a QSlider which is placed on a Qlabel?

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to rotate a QSlider?

    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.

  3. #3
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to rotate a QSlider?

    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 04:56. Reason: More Details

  4. #4
    Join Date
    Mar 2011
    Location
    Coimbatore,TamilNadu,India
    Posts
    382
    Thanks
    10
    Thanked 13 Times in 12 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: How to rotate a QSlider?

    Here is the code what I have tried.:
    Qt Code:
    1. QGraphicsScene *scene = new QGraphicsScene(this);
    2. ui->horizontalSlider->setParent(ui->graphicsView);
    3. QGraphicsProxyWidget *w = scene->addWidget(ui->horizontalSlider);
    4. w->setPos(0,45);
    5. w->setRotation(12);
    6. ui->graphicsView->setScene(scene);
    7. ui->graphicsView->show();
    8. ui->graphicsView->rotate(12);
    To copy to clipboard, switch view to plain text mode 

  5. #5
    Join Date
    Mar 2009
    Location
    Brisbane, Australia
    Posts
    7,729
    Thanks
    13
    Thanked 1,610 Times in 1,537 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows
    Wiki edits
    17

    Default Re: How to rotate a QSlider?

    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:
    1. #include <QtWidgets>
    2.  
    3. int main(int argc, char **argv) {
    4. QApplication app(argc, argv);
    5.  
    6. QSlider *slider = new QSlider();
    7.  
    8.  
    9. QGraphicsProxyWidget *p = scene.addWidget(slider);
    10. p->setRotation(20);
    11.  
    12. QGraphicsView view(&scene);
    13. view.show();
    14.  
    15. return app.exec();
    16. }
    To copy to clipboard, switch view to plain text mode 
    Attached Images Attached Images
    Last edited by ChrisW67; 3rd January 2018 at 08:46.

  6. The following user says thank you to ChrisW67 for this useful post:

    d_stranz (4th January 2018)

  7. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: How to rotate a QSlider?

    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.

Similar Threads

  1. QTransform rotate on X axis using QSlider
    By mvbhavsar in forum Newbie
    Replies: 7
    Last Post: 27th July 2012, 08:40
  2. Replies: 4
    Last Post: 1st December 2011, 20:53
  3. qslider
    By weixj2003ld in forum Qt Programming
    Replies: 5
    Last Post: 5th November 2011, 15:08
  4. Help Qslider
    By superteny in forum Qt Programming
    Replies: 5
    Last Post: 9th July 2009, 11:03
  5. QSlider
    By ToddAtWSU in forum Qt Programming
    Replies: 3
    Last Post: 10th May 2006, 17:41

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.