Is it possible to make a slider with an image? not as a background but like an image i pull up and down instead of the slider?
I have searched around and saw some examples of redrawing a slider, is it something like this i need to do, if so any examples you can link me too?
Also saw something called QML slider, can my project be achieved with that, if so any examples would be great!
I should mention im new to Qt and programming in general, so sorry in advance for any stupid mistakes i migth make .
With the Slider from Qt Quick Controls:
import QtQuick 2.2
import QtQuick.Controls 1.1
import QtQuick.Controls.Styles 1.1
Item {
width: 400
height: 400
Slider {
anchors.centerIn: parent
style: SliderStyle {
handle: Image {
source: "http://icons.iconarchive.com/icons/custom-icon-design/pretty-office-9/256/square-icon.png"
width: 14
height: 14
}
}
}
}
See SliderStyle's documentation for more information.
In Qt, you can customize almost all of the UI with stylesheets. For the documentation and a quick tutorial, you might want to take a look to here and here.
I haven't tested this, but it might work(please note that you will have to adde the handle to the qrc):
setStyleSheet("QSlider::handle:horizontal{background-image:url(:/images/fancySliderHandle.png);}");
You might also want to check here for documentation(under QSlider
). A syntax guide (in case you will be having trouble with my approach) can be found here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With