combining QTime with QLCD
-
Hello guys. How can i combine the time with my QLCD? I can display the lcd but it does not run. I want the time to run up to 6 minutes from 0.
#include "lcduuuuu.h" lcduuuuu::lcduuuuu(QWidget *parent):QLCDNumber(parent) { this->setGeometry(150,150,150,150); this->setDigitCount(5); this->display("00:00"); timee = new QTime(0,6,0); //time timerCount = new QTimer(this); //timer QObject::connect(timerCount, &QTimer::timeout,this,&lcduuuuu::timerCountSlot); } void lcduuuuu::timerCountSlot() { timee->addMSecs(360); timerCount->start(1000); }
-
Hi,
In your code you don't start the timer.
-
You realize that you don't update the content of your QLCDNumber subclass in that slot ?
-
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. } }
-
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. } }
-
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
-
@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 the06
and the00
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 oneint
value, so I don't know what you are trying to do with twoint
s....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). -
Ok thx. I will make it with two QLCDNumber. I thought i can do that with one QLCDNumber and two integer.
-
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. -
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.@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 isflat
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?
- There is no such method as