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

  • SEARCH
  • Home
  • 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 8890573
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T22:32:00+00:00 2026-06-14T22:32:00+00:00

I am using Qt4 and Qt Creator. I cannot write a custom slot to

  • 0

I am using Qt4 and Qt Creator. I cannot write a custom slot to a progress bar in the UI. How to write a custom slot for a specific widget in the ui file ? In my scenario, signal is not from the ui element.

the below code produces an error while running:

mainwindow.h

#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include<QFile>
#include<QFileInfo>

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT

public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();

private slots:
    void on_btcopy_clicked();
    void on_btquit_clicked();
    void ChangeValue(qint64 val);

private:
    Ui::MainWindow *ui;
};

#endif // MAINWINDOW_H

mainwindow.cpp

#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);
}

MainWindow::~MainWindow()
{
    delete ui;
}

void MainWindow::on_btcopy_clicked()
{
    QFileInfo *qfi=new QFileInfo("C:\\Users\\kiran\\Desktop\\test\\a.iso");
    qDebug("%d" ,qfi->size());
    QFile *qf=new QFile();
    QFile fromFile("C:\\Users\\kiran\\Desktop\\test\\a.iso");
    QFile toFile("C:\\Users\\kiran\\Desktop\\test\\b.iso");
    ui->pbar->setMaximum(fromFile.size());
    fromFile.copy(toFile.fileName());

    connect(&toFile, SIGNAL(bytesWritten(qint64)), ui->pbar, SLOT(CangeValue(qint64)));
    qDebug("completed");
}

void MainWindow::on_btquit_clicked()
{
   exit(0);
}

void MainWindow::CangeValue(qint64 val)
{
    ui->pbar->setValue(val);
}

Error Message

Object::connect: No such slot ProgressBar::CangeValue(qint64)in..\untitled\mainwindow.cpp:26
    Object::connect:  (receiver name: 'pbar')
  • 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-14T22:32:01+00:00Added an answer on June 14, 2026 at 10:32 pm

    CangeValue is a slot in your MainWindow (for the record: it should be called ChangeValue).

    Therefore the third parameter in your connect(..) statement must be your main window, not the progress bar. Replace ui->pbar by this in your connect statement.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently writing a wizard-style application using Qt4. I am not using the
I'm using Ubuntu 10.04 and Qt4.6, and I've created an executable binary file on
How do I connect to the MySQL database using QT4 and Qt Creator? I
I'm using Qt Creator 2.0.1 (Qt 4.7). I need a widget which can hold
I have created an MDI application (using Qt 4.6) in Qt Creator and added
I'm writing a custom makefile project using QtCreator and I want to delete a
I'm using Qt4.8 on OSX Leopard and instead of qmake + QtCreator I want
I'd like to draw some statistics charts using QT4.7 , here are some examples:
I am slowly getting used to using the Qt4 GUI framework. In a project
I'm using C++ with QT4 for this. And when I try to send large

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.