Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Problem with lcdNumber
Forum Updated to NodeBB v4.3 + New Features

Problem with lcdNumber

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
7 Posts 5 Posters 564 Views 3 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.
  • I Offline
    I Offline
    iq0.0
    wrote on 22 Apr 2024, 16:30 last edited by
    #1

    I want to display an lcdNumber on my beaglebone onboard display.
    I have 2 module: CwWindow and I2CCW
    Class CwWindow:public QMainWindow, private Ui::CwWindow
    Private slots:
    void updatef();
    // signal-slot connection:
    connect(pushButton, SIGNAL(clicked() ), this, SLOT(updatef() ) );
    ...
    voidCwWindow::updatef() {
    I2CCW m_i2ccw; //object for Modul I2CCW
    m_i2ccw.get_sum();

    Module I2CCW has no signal-slot, and give only the correct value ´dB´ back to module CwWindow.
    void I2CCW::get_sum() {
    double dB = ....
    CwWindow cw; //object for module CwWindow
    cw.show_recPo(dB) ;

    // in module CwWindow
    void CwWindow::show_recPo(double dB) {
    recPo = dB;
    std.cout << recPo << ´\nˋ // give correct value ( -49.3)
    lcdNumber->display(recPo); //give value 0 !!!!

    When I give a number in slot function:
    void CwWindow::updatef() {
    lcdNumber->display(-49.3); //value is displayed correct
    What can I do to get the correct display in function
    show_recPo() ??

    J 1 Reply Last reply 22 Apr 2024, 16:48
    0
    • I iq0.0
      22 Apr 2024, 16:30

      I want to display an lcdNumber on my beaglebone onboard display.
      I have 2 module: CwWindow and I2CCW
      Class CwWindow:public QMainWindow, private Ui::CwWindow
      Private slots:
      void updatef();
      // signal-slot connection:
      connect(pushButton, SIGNAL(clicked() ), this, SLOT(updatef() ) );
      ...
      voidCwWindow::updatef() {
      I2CCW m_i2ccw; //object for Modul I2CCW
      m_i2ccw.get_sum();

      Module I2CCW has no signal-slot, and give only the correct value ´dB´ back to module CwWindow.
      void I2CCW::get_sum() {
      double dB = ....
      CwWindow cw; //object for module CwWindow
      cw.show_recPo(dB) ;

      // in module CwWindow
      void CwWindow::show_recPo(double dB) {
      recPo = dB;
      std.cout << recPo << ´\nˋ // give correct value ( -49.3)
      lcdNumber->display(recPo); //give value 0 !!!!

      When I give a number in slot function:
      void CwWindow::updatef() {
      lcdNumber->display(-49.3); //value is displayed correct
      What can I do to get the correct display in function
      show_recPo() ??

      J Offline
      J Offline
      JonB
      wrote on 22 Apr 2024, 16:48 last edited by
      #2

      @iq0-0
      QLCDNumber::display(double value) does not work in one place and then fail to work in another. Remove all your signal & slot connections. Just try

      double db = -49.3;
      lcdNumber->display(recPo);
      

      in both places. Make sure your lcdNumber instances are the same actual widget.

      A I 2 Replies Last reply 22 Apr 2024, 18:43
      2
      • J JonB
        22 Apr 2024, 16:48

        @iq0-0
        QLCDNumber::display(double value) does not work in one place and then fail to work in another. Remove all your signal & slot connections. Just try

        double db = -49.3;
        lcdNumber->display(recPo);
        

        in both places. Make sure your lcdNumber instances are the same actual widget.

        A Offline
        A Offline
        Axel Spoerl
        Moderators
        wrote on 22 Apr 2024, 18:43 last edited by Axel Spoerl
        #3

        QLCDNumber::display() is unfortunately an ambiguous slot, taking either an int or a double. That can have surprising effects, especially when dealing with PMF based connections.

        Using qOverload<double>(&QLCDNumber::display) in the connect statement should solve such issues.

        Software Engineer
        The Qt Company, Oslo

        P 1 Reply Last reply 23 Apr 2024, 04:55
        1
        • A Axel Spoerl
          22 Apr 2024, 18:43

          QLCDNumber::display() is unfortunately an ambiguous slot, taking either an int or a double. That can have surprising effects, especially when dealing with PMF based connections.

          Using qOverload<double>(&QLCDNumber::display) in the connect statement should solve such issues.

          P Offline
          P Offline
          Paul Colby
          wrote on 23 Apr 2024, 04:55 last edited by Paul Colby
          #4

          @Axel-Spoerl said in Problem with lcdNumber:

          QLCDNumber::display() is unfortunately an ambiguous slot, taking either an int or a double. That can have surprising effects, especially when dealing with PMF based connections.

          I don't see how that's relevant, given that slot is not being connected to (it's being invoked directly). Of course, it might well be relevant, I'm just not sure why. Would love to hear more if its something I'm missing :) Either way qOverload() is pretty cool - never knew about that one.

          @iq0-0, what is your QLCDNumber::mode set to? Only QLCDNumber::Dec supports floating points, the other are integer only.

          Assuming you are using QLCDNumber::Dec, I would set a break-point on this line:

          cdNumber->display(recPo); //give value 0 !!!!
          

          And then step into and through that function call. It's possible, for example, that:

          • recPo is being modified by some other code in between your qDebug and QLCDNumber::display() calls (we don't see the declaration, nor the full life-cycle of that member variable; do you have multi-threaded or async I/O happening? is that variable a double?); or
          • QLCDNumber::display() might be setting the value correctly, and later calls overwriting it to 0 before you see the results;
          • etc.

          As I said, I'd use the debugger to step into it, and if that doesn't reveal anything, then what @JonB suggested above. Or try @JonB's suggestion first. Either is good, IMO :)

          Cheers.

          1 Reply Last reply
          0
          • J JonB
            22 Apr 2024, 16:48

            @iq0-0
            QLCDNumber::display(double value) does not work in one place and then fail to work in another. Remove all your signal & slot connections. Just try

            double db = -49.3;
            lcdNumber->display(recPo);
            

            in both places. Make sure your lcdNumber instances are the same actual widget.

            I Offline
            I Offline
            iq0.0
            wrote on 28 Apr 2024, 16:28 last edited by
            #5

            @JonB
            Thank you for your replies.
            I tried by removing all signal & slot connections.
            In function ‚‘void CwWindow::show_recPo(double dB)‘ the
            result was ‚‘0‘ instead of the correct value (-49.3). The difference
            to with signal & slot was that ‚‘0‘ did not move to the left.

            In function ‚‘void CwWindow::updatef()‚‘ the resultat also is ‚‘0‘ .![alt text]([image url]([link url](![link url](image url))))

            1 Reply Last reply
            0
            • I Offline
              I Offline
              iq0.0
              wrote on 4 May 2024, 16:11 last edited by
              #6

              My mode is set to ‚‘QLCDNumber::Dec ‚‘. ‚‘RecPo’ is the correct double number.
              The problem is that the object ‚‘lcdNumber‚‘ ‚is not the same in the function ‚‘show_recPo(double dB) ‚‘ and in the slot ‚‘updatef()‚‘ .
              Whereas when I give a number in the slot ‚‘ updatef()‚‘ , ‚‘lcdNumber->display(number) ‚‘
              the display gives the correct number and in the function ‚‘show_recPo(double dB)‚‘
              it displays ‚‚‘0‘ .

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on 4 May 2024, 18:12 last edited by
                #7

                Hi,

                You call show_recPo in get_sum which uses a local object if type CwWindow hence it will to nothing to your main CwWindow.

                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
                1

                1/7

                22 Apr 2024, 16:30

                • Login

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