Results 1 to 2 of 2

Thread: Qt Calling function in main fun: Qt slider

  1. #1
    Join Date
    Oct 2015
    Posts
    2
    Qt products
    Qt3
    Platforms
    Unix/X11

    Default Qt Calling function in main fun: Qt slider

    Hello All,

    I am new to qt and cpp also. I am using qslider for my project. Here is the code:
    program.hprogram.cpp

    How can I call int pos in main function. to my knowledge int x= functionname(& variable), but I cannot call.
    Thans a lot in advance.

  2. #2
    Join Date
    Jun 2015
    Location
    India
    Posts
    185
    Thanks
    8
    Thanked 14 Times in 14 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Qt Calling function in main fun: Qt slider

    How can I call int pos in main function.
    Your question is not clear to me some how.

    if you want slider position, use
    QSlider::value()
    and you have a current change value with the help of onValueChanged(int value) // value is the current slider value


    If you want current slider value in some other place, have a public function in mainwindow which return
    slider->value()
    ;
    And call this where ever you want main/some other class where you have this mainwindow handle.


    i don't know what your doing with this code
    Qt Code:
    1. void MainWindow::onValueChanged(int value)
    2.  
    3. {
    4.  
    5. int pos = slider->sliderPosition();
    6. value=pos; //what are doing here, why are you overwriting value
    7. //.................
    8. }
    To copy to clipboard, switch view to plain text mode 
    Last edited by prasad_N; 7th October 2015 at 09:23.
    Thanks :-)

Similar Threads

  1. Replies: 5
    Last Post: 6th May 2015, 19:37
  2. calling a function with objects
    By herculis in forum Newbie
    Replies: 3
    Last Post: 28th August 2014, 10:36
  3. Calling Dialog Box from Main Window
    By simb22 in forum Newbie
    Replies: 3
    Last Post: 30th June 2012, 21:25
  4. QDialog - Calling Main Window Function
    By Preeteesh in forum Newbie
    Replies: 4
    Last Post: 20th June 2007, 18:41
  5. Replies: 4
    Last Post: 10th March 2007, 18:01

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.