Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT Designer Issue
Qt 6.11 is out! See what's new in the release blog

QT Designer Issue

Scheduled Pinned Locked Moved General and Desktop
4 Posts 3 Posters 3.1k Views 2 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • H Offline
    H Offline
    heedaf
    wrote on last edited by
    #1

    This is really a strange issue that I'm having that I thought would be a simple thing but it is really giving me a headache. I've got an LCDNumber display widget that I'm trying to write to. I've found some sample code that updates the a clock every second.

    void DigitalClock::showTime()
    {
    QTime time = QTime::currentTime();
    QString text = time.toString("hh:mm:ss");
    setDigitCount(8);
    if ((time.second() % 2) == 0)
    {
    text[5] = ' ';
    }
    display(text);
    // ui->lcdNumber->display(text);
    }

    I've included the //ui-->lcdNumber->display(text) as an example of what I'm trying to do. The following works just fine:

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

    Can anyone explain to me how I can get the DigitalClock section to update the lcdNumber box I created in QT creator?

    Thanks!

    1 Reply Last reply
    0
    • K Offline
      K Offline
      killerman
      wrote on last edited by
      #2

      You can create a signal in DigitalClock that will send the data and a slot in MainWindow that will receive it.

      QObject::connect(yourDigitalClock, SIGNAL(yourSignal(QString)),
                       yourMainWindow, SLOT(setDisplay(QString)));
      
      1 Reply Last reply
      0
      • H Offline
        H Offline
        heedaf
        wrote on last edited by heedaf
        #3

        Thanks for your reply! I've spent awhile on this and I could use more help. I've got the following

        void DigitalClock::showTime()
        {
        QTime time = QTime::currentTime();
        QString text = time.toString("hh:mm:ss");
        if ((time.second() % 2) == 0)
        text[2] = ' ';
        display(text);
        }

        I need to pass the QString "text" to a lcdNumber box in the MainWindow and I've tried multiple configurations but I'm just not sure how it works. Could you please fix the what I've done wrong?

        QObject::connect(showTime(), SIGNAL(time(Qstring)), MainWindow(), SLOT(ui->lcdNumber->Display(QString)));
        

        It gives a "No instance of overloaded function "QObject::connect" matches the argument list". I tried the following

        QObject connect(DigitalClock, SIGNAL(time(Qstring)), MainWindow(), SLOT(Display(QString)));

        and it gives me a "expected a type specifier" for the SIGNAL and the SLOT

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi,

          The SLOT macro only takes the slot name with argument type like shown in @killerman's example

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved