Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9141085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:36:00+00:00 2026-06-17T09:36:00+00:00

My environment is Qt5 32bit Windows 7 64bit MSVC 2010 32bit My code is

  • 0

My environment is Qt5 32bit Windows 7 64bit MSVC 2010 32bit

My code is a simple music player

this is main code

slider = new QSlider(Qt::Horizontal);
slider->setRange(0, 100);
player->setMedia(QUrl::fromLocalFile("D://test.mp3"));
player->setVolume(50);
...
connect(player, SIGNAL(bufferStatusChanged(int)), slider, SLOT(setValue(int)));

When I run this player, it could play music, but the value of the slider never changed.

then I add this:

connect(player, SIGNAL(bufferStatusChanged(int)), slider, SLOT(helloWorld(int)));
...
void player::helloWorld(int)
{
    qDebug() << "hello, world";
}

I run it again, and found the string hello, world never be printed.

not printed anything.

Why the value of the slider not be changed?

————————-full code————————–

#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{

    mainWidget = new QWidget();
    HLayout = new QHBoxLayout();
    VLayout = new QVBoxLayout();

    playButton = new QPushButton("Okay");
    exitButton = new QPushButton("Exit");
    slider = new QSlider(Qt::Horizontal);
    player = new QMediaPlayer();

    connect(playButton, SIGNAL(toggled(bool)), this, SLOT(playOrPause(bool)));
    connect(player, SIGNAL(bufferStatusChanged(int)), slider, SLOT(setValue(int)));
    connect(player, SIGNAL(bufferStatusChanged(int)), this, SLOT(test(int)));
    player->setMedia(QUrl::fromLocalFile("D://test.mp3"));
    player->play();
    player->setVolume(50);
    slider->setRange(0, 100);


    //UI
    exitButton->setAutoDefault(true);
    playButton->setAutoDefault(true);
    playButton->setCheckable(true);

    HLayout->addStretch();
    HLayout->addWidget(playButton);
    HLayout->addWidget(exitButton);

    VLayout->addWidget(slider);
    VLayout->addStretch();
    VLayout->addLayout(HLayout);

    mainWidget->setLayout(VLayout);

    setCentralWidget(mainWidget);
    setWindowIcon(QIcon(":/icons/icon.png"));
    setWindowTitle("YUCOAT");

    //connect(playButton, SIGNAL(toggled(bool)), this, SLOT(playOrPause(bool)));
    //connect(player, SIGNAL(bufferStatusChanged(int)), slider, SLOT(setValue(int)));

}

MainWindow::~MainWindow()
{

}

void MainWindow::playOrPause(bool s)
{
    if (s)
        player->play();
    else
        player->pause();

}

void MainWindow::test(int s)
{
    qDebug() << "hello, world!";
    qDebug() << s;
    qDebug() << player->mediaStatus();
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T09:36:01+00:00Added an answer on June 17, 2026 at 9:36 am

    According to the documentation :

    When the player object is buffering; this property holds the
    percentage of the temporary buffer that is filled. The buffer will
    need to reach 100% filled before playback can resume, at which time
    the MediaStatus will be BufferedMedia.

    You are making the connection after loading the media so probably the buffer is already in a QMediaPlayer::BufferedMedia state so the signal will not get emited. You could check it by printing the media status before the connection:

    qDebug() << player->mediaStatus();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Environment: Flex 3.6 Look at this piece of code: var arr:Array = new Array()
Environment: Visual Studio Ultimate 2010 Windows XP WPF Desktop Application using .NET 4.0 We
Environment: Windows 7 SP1 Visual Studio 2010 Ultimate SP1 .NET 4.0 I have a
Environment: Visual Studio Ultimate 2010 .NET 4.0 Windows XP, Vista and 7 We have
Environment: Main platform: MAC OSX 10.6 Secondary platform via VMWare Fusion: Windows 7 64-bit
Environment: Windows Server 2003 R2 Enterprise 64bit, SP2 .NET framework is supposedly installed (2.0
Environment: Windows Server 2008 R2 on Amazon EC2 Netbeans IDE with Glassfish started on
Environment info: *Windows Vista *PHP 5.2.9-2 I'm working on a project. Let's say it's
ENVIRONMENT: C# I have a table of equivalent values, like this: CHEVR = CHEVROLET
Environment: Seam, Richfaces The following code snippet causes the method getUsers to be called

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.