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. combining QTime with QLCD
Forum Updated to NodeBB v4.3 + New Features

combining QTime with QLCD

Scheduled Pinned Locked Moved Unsolved General and Desktop
18 Posts 3 Posters 1.1k Views 1 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.
  • T Offline
    T Offline
    thomasGl
    wrote on last edited by
    #5

    Hi, i am getting weird jumps from 0 to 8 i dont understand...... . I want to count to 60 in one step

    #include "mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
    {
    
    
    
        QLCDNumber* lcd= new QLCDNumber(this);
    
    
        QObject::connect(timer,&QTimer::timeout,this,&MainWindow::displaySeconds);timer->start(1000);
    
    
    
    }
    
    
    void MainWindow::displaySeconds()
    {
        if(counter<=60)
        {
            counter++;
            qDebug()<<counter;    //that works in one step
            lcd->display(counter);  //that does not.
        }
    
    
    
    }
    
    
    JonBJ 1 Reply Last reply
    0
    • T thomasGl

      Hi, i am getting weird jumps from 0 to 8 i dont understand...... . I want to count to 60 in one step

      #include "mainwindow.h"
      
      MainWindow::MainWindow(QWidget *parent)
          : QMainWindow(parent)
      {
      
      
      
          QLCDNumber* lcd= new QLCDNumber(this);
      
      
          QObject::connect(timer,&QTimer::timeout,this,&MainWindow::displaySeconds);timer->start(1000);
      
      
      
      }
      
      
      void MainWindow::displaySeconds()
      {
          if(counter<=60)
          {
              counter++;
              qDebug()<<counter;    //that works in one step
              lcd->display(counter);  //that does not.
          }
      
      
      
      }
      
      
      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by JonB
      #6

      @thomasGl
      The code you show cannot work. In the slot you access lcd variable, but in MainWindow::MainWindow you show QLCDNumber* lcd= new QLCDNumber(this); which is a local variable so it cannot be that QLCDNumber.

      1 Reply Last reply
      3
      • T Offline
        T Offline
        thomasGl
        wrote on last edited by
        #7

        hello, is there a method to convert that string into a int? I can make two lcdnumbers with int num1; and int num2; but maybe there is a way to dispaly only 1 lcdnumber with 2 numbers.

          num1->display("06:00");  //display that as an int   
        
        JonBJ 1 Reply Last reply
        0
        • T thomasGl

          hello, is there a method to convert that string into a int? I can make two lcdnumbers with int num1; and int num2; but maybe there is a way to dispaly only 1 lcdnumber with 2 numbers.

            num1->display("06:00");  //display that as an int   
          
          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #8

          @thomasGl
          How do you want to convert the string 06:00 to an int --- what value would you want?

          1 Reply Last reply
          0
          • T Offline
            T Offline
            thomasGl
            wrote on last edited by
            #9

            Yes, i want an int=6;

            JonBJ 1 Reply Last reply
            0
            • T thomasGl

              Yes, i want an int=6;

              JonBJ Offline
              JonBJ Offline
              JonB
              wrote on last edited by
              #10

              @thomasGl
              So you want the first number in the string, and ignore the :00? So if you want to convert a QString to a number did you look in the QString Class documentation and search for number?

              1 Reply Last reply
              0
              • T Offline
                T Offline
                thomasGl
                wrote on last edited by
                #11

                yeah i want the :00 also. I will look in the documentation and hope to understand.

                JonBJ 1 Reply Last reply
                0
                • T thomasGl

                  yeah i want the :00 also. I will look in the documentation and hope to understand.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by JonB
                  #12

                  @thomasGl said in combining QTime with QLCD:

                  Yes, i want an int=6;
                  yeah i want the :00 also.

                  :) If you want to get at the 00 you could use QString::mid(3), or you could QString::split(":") to get the 06 and the 00 as separate strings.

                  I don't understand what you are trying to do with a string and parsing it, though. And one QLCDNumber can only display one int value, so I don't know what you are trying to do with two ints....

                  Let's restart with the title of this topic. So you want to display some kind of current time, or elapsed timer ("I want the time to run up to 6 minutes from 0"), as an LCD clock like e.g. 01:23? Then you should start with example Digital Clock Example. That seems to show the current clock time (QTime::currentTime()). Sounds like you want a QElapsedTimer instead (QElapsedTimer::elapsed() returns milliseconds).

                  1 Reply Last reply
                  0
                  • T Offline
                    T Offline
                    thomasGl
                    wrote on last edited by
                    #13

                    Ok thx. I will make it with two QLCDNumber. I thought i can do that with one QLCDNumber and two integer.

                    JonBJ 1 Reply Last reply
                    0
                    • T thomasGl

                      Ok thx. I will make it with two QLCDNumber. I thought i can do that with one QLCDNumber and two integer.

                      JonBJ Offline
                      JonBJ Offline
                      JonB
                      wrote on last edited by
                      #14

                      @thomasGl
                      But that is so sad when I gave you the example code which does what you want with one QLCDNumber! Did you even look at it?

                      1 Reply Last reply
                      0
                      • T Offline
                        T Offline
                        thomasGl
                        wrote on last edited by thomasGl
                        #15

                        QString::mid(3), or you could QString::split(":") i will try that yes

                        1 Reply Last reply
                        0
                        • T Offline
                          T Offline
                          thomasGl
                          wrote on last edited by
                          #16

                          Hello. What are the parameters of SegmentStyle(); and digitCount();

                          lcd->SegmentStyle(flat);   //does not work and 2 also
                          lcd->digitCount(2)  //does not work
                          

                          the documentation says QLCDNumber::Flat is 2 but that does not work .
                          And digitCount needs an int but that does not work either.

                          JonBJ 1 Reply Last reply
                          0
                          • T thomasGl

                            Hello. What are the parameters of SegmentStyle(); and digitCount();

                            lcd->SegmentStyle(flat);   //does not work and 2 also
                            lcd->digitCount(2)  //does not work
                            

                            the documentation says QLCDNumber::Flat is 2 but that does not work .
                            And digitCount needs an int but that does not work either.

                            JonBJ Offline
                            JonBJ Offline
                            JonB
                            wrote on last edited by
                            #17

                            @thomasGl said in combining QTime with QLCD:

                            What are the parameters of SegmentStyle(); and digitCount();

                            Use the documentation to discover exactly this, that's what it's there for.

                            • There is no such method as QLCDNumber::SegmentStyle(), so it won't compile. Nor is flat a recognised value or variable.
                            • QLCDNumber::digitCount() does not accept any parameter, and does not set the digit count anyway.

                            lcd->digitCount(2) //does not work

                            Instead of just typing this in and wondering why it does not work and how to do it, why not go back to your code in your very first post here. Doesn't that have a statement setting the digit count to 5?

                            1 Reply Last reply
                            1
                            • T Offline
                              T Offline
                              thomasGl
                              wrote on last edited by
                              #18

                              thx i got it.

                              1 Reply Last reply
                              1

                              • Login

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