Results 1 to 2 of 2

Thread: Changing Slider Base

  1. #1
    Join Date
    Dec 2010
    Location
    My bed
    Posts
    21
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Changing Slider Base

    I'm writing a program where you move a slider and the number on QLCDNumber changes accordingly. I want to add a couple of buttons which will change the base of the slider (from decimal base to binary/hexadecimal).
    This is the code that i've written - the main line is in bold.
    The program compiles - but when I click on the button, the base doesn't change.
    What's wrong here?

    Qt Code:
    1. QLCDNumber *lcd=new QLCDNumber(3,this);
    2. lcd->setMode(QLCDNumber::Dec);
    3. lcd->setGeometry(50,25,100,100);
    4.  
    5. QSlider *slide = new QSlider(Qt::Horizontal,this);
    6. slide->setRange(0,100);
    7. slide->setValue(0);
    8. slide->setGeometry(50,125,100,25);
    9.  
    10. connect(slide,SIGNAL(sliderMoved(int)),lcd,SLOT(display(int)));
    11.  
    12. QPushButton *hex = new QPushButton("Hexadecimal",this);
    13. hex->setFont(QFont("Times",12));
    14. hex->setGeometry(50,200,100,25);
    15.  
    16. [B]connect(hex,SIGNAL(clicked()),lcd,SLOT(setMode(QLCDNumber::Hex)));[/B]
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Dec 2010
    Location
    My bed
    Posts
    21
    Thanks
    7
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Changing Slider Base

    Got it, Thanks!
    line 16 should have been
    Qt Code:
    1. connect(hex, SIGNAL(clicked()),lcd,SLOT(setHexMode());
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. QSlider: changing the groove without changing the handle
    By Olivier Berten in forum Qt Programming
    Replies: 3
    Last Post: 30th April 2013, 10:02
  2. Replies: 2
    Last Post: 21st March 2010, 09:01
  3. Replies: 2
    Last Post: 10th August 2009, 09:45
  4. get slider value
    By eric in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2007, 19:47
  5. Shape changing under other tab using slider/spinbox
    By kramed in forum Qt Programming
    Replies: 2
    Last Post: 7th August 2007, 19:59

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.