close

image

使用元件 :horizontalSlider

 

.h

 

1
2
3
4
5
protected:
    void wheelEvent(QWheelEvent * e);

public:
    int s;

 

.cpp

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
void music_play::wheelEvent(QWheelEvent *event)
{
    QPoint numDegrees = event->angleDelta();
    if(numDegrees.y()>0 && s<=100){
        s++;
    }else if(s>=0){
        s--;
    }
     ui->horizontalSlider->setValue(s);
}

 

numDegress 往前滾是正值,往後滾是負值。

arrow
arrow
    創作者介紹
    創作者 讀書小天地 的頭像
    讀書小天地

    書籍分享天地

    讀書小天地 發表在 痞客邦 留言(0) 人氣()