Results 1 to 4 of 4

Thread: I Need Some Help With QObject::connect: No such signal QCommandLinkButton::click()

  1. #1
    Join Date
    Jun 2017
    Location
    Damascus-Syria
    Posts
    6
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default 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:
    Qt Code:
    1. #include "numericalsystemsconverter.h"
    2. #include "ui_numericalsystemsconverter.h"
    3. #include <Qt>
    4. #include <QLabel>
    5. #include <QLineEdit>
    6. #include <QCommandLinkButton>
    7.  
    8. NumericalSystemsConverter::NumericalSystemsConverter(QWidget *parent) :
    9. QMainWindow(parent),
    10. ui(new Ui::NumericalSystemsConverter)
    11. {
    12. ui->setupUi(this);
    13.  
    14.  
    15. QLabel *title=new QLabel(this);
    16. title->setGeometry(0,0,400,30);
    17. title->setStyleSheet("font-size:20px;");
    18. title->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    19. title->setText("Numerical Systems Converter");
    20.  
    21. QLineEdit *decimal_entry=new QLineEdit(this);
    22. decimal_entry->setGeometry(0,50,400,30);
    23. decimal_entry->setClearButtonEnabled(true);
    24. decimal_entry->setStyleSheet("font-size:20px;");
    25. decimal_entry->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    26. decimal_entry->setPlaceholderText("Enter Your Decimal Number Here...");
    27.  
    28. QCommandLinkButton *dec2bin=new QCommandLinkButton(this);
    29. dec2bin->setGeometry(0,90,400,50);
    30. dec2bin->setStyleSheet("font-size:20px;");
    31. dec2bin->setText("Convert To Binary");
    32.  
    33. QLabel *result=new QLabel(this);
    34. result->setGeometry(0,250,400,30);
    35. result->setStyleSheet("font-size:20px;");
    36. result->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter);
    37. result->setText("The Result Should Appear Here...");
    38.  
    39. QObject::connect(dec2bin,SIGNAL(click()),result,SLOT(QLabel::setText("Hello World")));
    40. }
    41.  
    42. NumericalSystemsConverter::~NumericalSystemsConverter()
    43. {
    44. delete ui;
    45. }
    To copy to clipboard, switch view to plain text mode 

    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?

  2. #2
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default 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

  3. #3
    Join Date
    Jun 2017
    Location
    Damascus-Syria
    Posts
    6
    Thanks
    1
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: I Need Some Help With QObject::connect: No such signal QCommandLinkButton::click(

    Quote Originally Posted by Ginsengelf View Post
    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?

  4. #4
    Join Date
    Jul 2008
    Location
    Germany
    Posts
    503
    Thanks
    11
    Thanked 76 Times in 74 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: I Need Some Help With QObject::connect: No such signal QCommandLinkButton::click(

    Hi, something like this:
    Qt Code:
    1. {
    2. ....
    3. QObject::connect(dec2bin,SIGNAL(clicked()),this,SLOT(slotSetLabelText()));
    4. }
    5.  
    6. void NumericalSystemsConverter::slotSetLabelText()
    7. {
    8. result->setText("Hello World"); // this assumes result is a member of NumericalSystemsConverter
    9. }
    To copy to clipboard, switch view to plain text mode 

    Ginsengelf

  5. The following user says thank you to Ginsengelf for this useful post:

    Syrian Lucianos (23rd June 2017)

Similar Threads

  1. Replies: 6
    Last Post: 1st May 2014, 03:30
  2. Replies: 9
    Last Post: 5th February 2013, 16:31
  3. QObject::connect: Connecting from COMPAT signal...
    By ricardo in forum Qt Programming
    Replies: 1
    Last Post: 29th June 2009, 18:09
  4. QObject::connect: No such signal
    By caseyong in forum Qt Programming
    Replies: 5
    Last Post: 19th February 2008, 08:23

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.