[SOLVED]Problem with horizontalScrollBar



  • i have such a problem, in class "a" i have a scrollbar and in class "b" i have a variable int x. What I want to do is to change the variable x when i change a value in slider.

    in class "a" i have:
    @QObject::connect(ui->horizontalScrollBar,SIGNAL(valueChanged(int)),object of class "b" , SLOT(change_x())); @

    in class "b" i have variable int x, and SLOT change_x()

    @void b::change_x(){
    x= ....;
    }@

    what i should add to this code to make this run, i know it's may be a simple but i'm a beginner


  • Moderators

    try this :
    @connect(a.scrollbar,SIGNAL(valuechanged(int), b, SLOT(change_x(int)));@

    your slot needs an int as variable :
    @void b::change_x(int val){ x= ....; } @



  • Just change your slot like this:

    @void b::setX(int newX){ x = newX; }@

    The rest is the same, just update your header file to
    @
    ...
    private slots:
    void setX(int);
    ...
    }@
    and

    @connect(...,...,...,SLOT(setX(int));@



  • yeah, it's work, thank You for fast reply


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.