Results 1 to 5 of 5

Thread: [HELP] how to get a value of slider from ui_XXXX.h

  1. #1
    Join Date
    Jun 2014
    Posts
    33
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Exclamation [HELP] how to get a value of slider from ui_XXXX.h

    Hi all,

    newly register, new to Qt here.

    Here is a new question:

    I am recently designing a GUI using dialog.ui
    i used a lot of slider, i need to read the slider value,
    anyone tell me how can i get it from ui_dialog.h ?
    is it possible?
    here is a photo of GUI:
    snapshot1.jpg

    After this question, i would like to save these values that i get from slider in to a text file that using XML format.
    How can i achieve this?

    Please advise,

    Best regards,
    YDYD

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: [HELP] how to get a value of slider from ui_XXXX.h

    If you have chosen a designer form class template in QtCreator then you should have a dialog.h and a dialog.cpp generated with the .ui file.

    The dialog.cpp will have an include for the generated header and have created an instance of the class and stored that in the "ui" pointer.

    The code to access any widget present in the designer form is then
    Qt Code:
    1. ui->nameOfTheWidget
    To copy to clipboard, switch view to plain text mode 

    e.g. for a slider named "slider1", getting the value would be
    Qt Code:
    1. int value = ui->slider1->value();
    To copy to clipboard, switch view to plain text mode 

    Cheers,
    _

  3. #3
    Join Date
    Jun 2014
    Posts
    33
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [HELP] how to get a value of slider from ui_XXXX.h

    Hi anda_skoa,

    appreciate this!

    this help me a lot!


    Added after 8 minutes:


    Hi,
    can i printf in LXterminal for checking value of
    Qt Code:
    1. int value
    To copy to clipboard, switch view to plain text mode 
    ?

    and one more question:

    Could i save the value i get into a .TXT file?
    Last edited by YDYD; 30th June 2014 at 10:54.

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: [HELP] how to get a value of slider from ui_XXXX.h

    Quote Originally Posted by YDYD View Post
    can i printf in LXterminal for checking value of
    Qt Code:
    1. int value
    To copy to clipboard, switch view to plain text mode 
    ?
    Qt Code:
    1. qDebug() << value;
    To copy to clipboard, switch view to plain text mode 

    Quote Originally Posted by YDYD View Post
    and one more question:

    Could i save the value i get into a .TXT file?
    See QFile and QTextStream.

    Cheers,
    _

  5. #5
    Join Date
    Jun 2014
    Posts
    33
    Thanks
    15
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: [HELP] how to get a value of slider from ui_XXXX.h

    Hi,

    i did try this the whole day, i just could sote the value in a txt file... i did as following :
    Qt Code:
    1. int h_slide1 = ui->hueSlide1->value();
    2. QFile valueHSV("/home/pi/valueHSV/hsv.txt")
    3. if(!valueHSV.open(QIODevice::WriteOnly| QIODevice::Append))
    4. return;
    5. QTextStream hsv(&valueHSV);
    6. hsv << h_slide1;
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. Dynamic label to right of slider resizes slider
    By zenzero-2001 in forum Qt Programming
    Replies: 2
    Last Post: 3rd October 2013, 10:11
  2. help on my slider
    By newb in forum Qt Programming
    Replies: 1
    Last Post: 13th July 2010, 15:36
  3. Replies: 2
    Last Post: 21st March 2010, 09:01
  4. Rotating a slider...
    By ACFred in forum Newbie
    Replies: 7
    Last Post: 24th February 2008, 15:56
  5. get slider value
    By eric in forum Qt Programming
    Replies: 1
    Last Post: 8th November 2007, 19:47

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.