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 7636865
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:47:35+00:00 2026-05-31T07:47:35+00:00

I’ve got some problem with signal for a button in Qt 4.8.0. I am

  • 0

I’ve got some problem with signal for a button in Qt 4.8.0. I am using vs 2010 with Qt Designer. I have created a button in Designer with playButton name. But after that I tried to connect clicked() signal (in vs) with my function from CRenderArea (to start a timer), but it seems that it doesn’t work (the function start() works when I put it in the constructor, so it’s not the problem of the code itself). The code is compiling, the program is executing, but after clicking a button – nothing happens (it should move a line).

I would be really thankful for some help, just started a fun with Qt.

The codes are here (I hope the number of files won’t scare you, these are the simplest codes ever 🙂 ):

main.cpp

#include "ts_simulator.h"
#include <QtGui/QApplication>

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);
    TS_simulator w;
    w.show();
    return a.exec();
}

ts_simulator.cpp:

TS_simulator::TS_simulator(QWidget *parent, Qt::WFlags flags)
    : QMainWindow(parent, flags)
{
    p_map = new CRenderArea();
    ui.setupUi( this );
    p_map->setParent( ui.renderArea );

    // this doesn't work, why?
    connect( ui.playButton, SIGNAL( clicked() ), this, SLOT( p_map->start() ) );
}

CRenderArea.h

#pragma once

#include <QtGui>

class CRenderArea : public QWidget {
    Q_OBJECT // I think it's necessary?

    int x;
    QBasicTimer* timer;
public:
    CRenderArea();
public slots: // this is necessary too, right?
    void start();
private:
    void timerEvent( QTimerEvent* );
    void paintEvent( QPaintEvent* );
};

and CRenderArea.cpp:

#include "CRenderArea.h"

CRenderArea::CRenderArea() : x( 0 ) {
    setBackgroundRole( QPalette::Base );
    setMinimumSize( 591, 561 );
    setAutoFillBackground( true );
    timer = new QBasicTimer();

}

void CRenderArea::timerEvent( QTimerEvent* e ) {
    ++x;
    update();
}

void CRenderArea::paintEvent( QPaintEvent* p ) {
    QPainter painter(this);
    painter.setRenderHint(QPainter::Antialiasing);
    painter.setPen(Qt::darkGray);
    painter.drawLine(2+x/10, 8, 60, 300);
}

void CRenderArea::start() {
    timer->start( 0, this );
}

Greets.

  • 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-05-31T07:47:36+00:00Added an answer on May 31, 2026 at 7:47 am

    The problem is here:

    connect( ui.playButton, SIGNAL( clicked() ), this, SLOT( p_map->start() ) );

    if p_map is the receiver of the signal, and it has Q_OBJECT, it should be written as:

    connect( ui.playButton, SIGNAL( clicked() ), p_map, SLOT(start()) );

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

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I have thousands of HTML files to process using Groovy/Java and I need to
I have some data like this: 1 2 3 4 5 9 2 6
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't

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.