Unsolved Slider
-
This post is deleted! -
Hi,
Do you mean connect the MediaPlayer::position property or the Video::position property to the Slider::value property ?
-
media player position property where we use media player and video output, i have displayed video and did all the things, i want to know how to move slider as video progresses, could u help ?
-
Did you already read the Property Binding chapter of Qt's documentation ?
-
@SGaist i read, but i am not getting idea how to do it
-
Can you show the QML code you are using ?
-
Qml code:
Window
{
visible: true
width: 640
height: 480
title: qsTr("Hello World")Slider { id: slid x: 26 y: 118 width: 585 height: 32 from:0 to:100 stepSize: 1 // here can we give 100ms check for that. } Rectangle { id: start x: 217 y: 269 width: 71 height: 45 border.color: "black" Text { id: starttxt text: qsTr("Start") anchors.centerIn: parent } MouseArea { anchors.fill: parent onClicked: { bhushanuser.checkbutton(1) } } } Rectangle { id: stop x: 360 y: 269 width: 71 height: 45 border.color: "black" Text { id: stoptxt text: qsTr("stop") anchors.centerIn: parent } MouseArea { anchors.fill: parent onClicked: { bhushanuser.checkbutton(0) } } } Connections { target: bhushanuser onPlay: { slid.increase() } onPause: { slid.decrease() } }
}
main.cpp:-
#include <QGuiApplication>
#include <QQmlApplicationEngine>
#include <QQmlContext>
#include <QQmlEngine>
#include "slider.h"int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);slider *user = new slider; QQmlApplicationEngine engine; QQmlContext *context = engine.rootContext(); context->setContextProperty("bhushanuser",user); engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); if (engine.rootObjects().isEmpty()) return -1; return app.exec();
}
slider.cpp
#include "slider.h"
#include <QDebug>slider::slider(QObject *parent) : QObject(parent)
{}
void slider::checkbutton(int playpause)
{
if(playpause==1)
{
emit play();
}if(playpause==0) { emit pause(); }
}
slider.h
#ifndef SLIDER_H
#define SLIDER_H#include <QObject>
class slider : public QObject
{
Q_OBJECT
public:
explicit slider(QObject *parent = nullptr);signals:
void play();
void pause();
public slots:
void checkbutton(int playpause);
};#endif // SLIDER_H
As of know, i am doing this thing that after clicking on start button slider will move, i want it to move continue, until i dont pressed stop button.
-
You now have an answer in your other thread on almost the same subject.