I Need Some Help With QObject::connect: No such signal QCommandLinkButton::click()
hello everyone this is my first post here...
i'am making a simple c++ program with gui,i'am building the gui manually using QCommandLinkButton and QLabel and QLineEdit,here's the code:
numericalsystemsconverter.cpp:
Code:
#include "numericalsystemsconverter.h"
#include "ui_numericalsystemsconverter.h"
#include <Qt>
#include <QLabel>
#include <QLineEdit>
#include <QCommandLinkButton>
NumericalSystemsConverter
::NumericalSystemsConverter(QWidget *parent
) : ui(new Ui::NumericalSystemsConverter)
{
ui->setupUi(this);
title->setGeometry(0,0,400,30);
title->setStyleSheet("font-size:20px;");
title->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
title->setText("Numerical Systems Converter");
decimal_entry->setGeometry(0,50,400,30);
decimal_entry->setClearButtonEnabled(true);
decimal_entry->setStyleSheet("font-size:20px;");
decimal_entry->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
decimal_entry->setPlaceholderText("Enter Your Decimal Number Here...");
QCommandLinkButton *dec2bin=new QCommandLinkButton(this);
dec2bin->setGeometry(0,90,400,50);
dec2bin->setStyleSheet("font-size:20px;");
dec2bin->setText("Convert To Binary");
result->setGeometry(0,250,400,30);
result->setStyleSheet("font-size:20px;");
result->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
result->setText("The Result Should Appear Here...");
QObject::connect(dec2bin,
SIGNAL(click
()),result,
SLOT(QLabel::setText("Hello World")));
}
NumericalSystemsConverter::~NumericalSystemsConverter()
{
delete ui;
}
whenever i compile this code the gui appears successfully,but in the Application Output i see this message:
QObject::connect: No such signal QCommandLinkButton::click()
how to solve this problem?
Re: I Need Some Help With QObject::connect: No such signal QCommandLinkButton::click(
Hi, multiple problems here:
1) the signal is called clicked(), not click()
2) you cannot pass values inside the connect() call like the "Hello World" string. Also don't write QLabel::setText. Instead write only the name of the slot. The class is determined by the type of the receiving object, in this case "result".
Best regards,
Ginsengelf
Re: I Need Some Help With QObject::connect: No such signal QCommandLinkButton::click(
Quote:
Originally Posted by
Ginsengelf
Hi, multiple problems here:
1) the signal is called clicked(), not click()
2) you cannot pass values inside the connect() call like the "Hello World" string. Also don't write QLabel::setText. Instead write only the name of the slot. The class is determined by the type of the receiving object, in this case "result".
Best regards,
Ginsengelf
thank you very much sir,i just want to understand the second part of your answer,can you give me an example?
Re: I Need Some Help With QObject::connect: No such signal QCommandLinkButton::click(
Hi, something like this:
Code:
{
....
QObject::connect(dec2bin,
SIGNAL(clicked
()),
this,
SLOT(slotSetLabelText
()));
}
void NumericalSystemsConverter::slotSetLabelText()
{
result->setText("Hello World"); // this assumes result is a member of NumericalSystemsConverter
}
Ginsengelf