Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Qt 5.9.8 errors with timers and buttons



  • I did install Qt 5.9.8 minGw_530 with MinGW 4.8 and 4.9.2, my friend has windows 10, i did send him my software for testing, and he has problems with timers and buttons.

    The timers start but you need 2 or 3 buttons click just to start it and it's consistent.
    Messy thing is i did send him exactly the same code with qt 5.2.1, and there is not a single issue with it.... I am out of ideas how to fix it, basically i have qt 5.8, 5.9.8 and they all create the same or more errors related to timer start, when i am using qt 5.2.1 there is not a single issue.

    Help because i am out of ideas how to fix it, i already lost more time then i can afford.
    Because i am using custom timer, i will show the start function:

    
    void Timer::Start(int refire_time)
    {
        if(this->started == false)
        {
            this->timer.start(refire_time);
            this->time.start();
        }
        else
        {
            this->difference = this->elapsed_time.fromMSecsSinceStartOfDay(this->elapsed_time.elapsed()).elapsed();
        }
        this->time = QTime::fromMSecsSinceStartOfDay(this->elapsed_time.elapsed());
        this->started = true;
    }
    

    This is from the button:

    void Main_Window::on_start_stopwatch_button_pressed()
    {
        if(this->timer->Is_Started() == true)
        {
            this->timer->Stop();
            this->ui->start_stopwatch_button->setText("Start");
        }
        else
        {
            this->timer->Start(1);
            this->ui->start_stopwatch_button->setText("Stop");
        }
    }
    

  • Qt Champions 2019

    What is 'elapsed_time', what should QTime::fromMSecsSinceStartOfDay() do and why do you use 'this->' everywhere? C++ is not java and it just makes the code unreadable. Use a proper notation for the members (e.g. let them start with 'm_')


  • Lifetime Qt Champion

    @Loc888

    I did install Qt 5.9.8 minGw_530 with MinGW 4.8 and 4.9.2

    Qt is compiled with MinGW 5.3.0, so you should use exactly that version. You can install it with MaintenanceTool.



  • @Christian-Ehrlicher If this code is unreadable, then it means just it's unreadable for you, i use this whenever i use any member, so what is the point to use m_? Also this change the color to green, and for me is much better to read it.

    The correct question should be, why is it working for me, why is it working with Qt 5.2.1, and why is NOT working with qt 5.9.8 on my friend's PC.



  • @aha_1980 Listen, this is what your QT team put to the package, i did download Qt 5.9.8 and there was MinGw 4.9.2, i am not sure if those names are also even correct. With this approach Qt 5.2 should not work too, because it's using MinGW 4.8.

    Qt maintance tool.... I am not even comment it, this is how helpfull it is https://forum.qt.io/topic/102119/qt-charts-installation/5


  • Lifetime Qt Champion

    @Loc888
    Hi
    Just a quick question?
    You send your friend the source code ?
    and he compiles with qt 5.9.8 and it works differently ?
    Or do you send him a binary exe WITH the needed dlls ?



  • @mrjj Binary exe with DLL's, like i said the SAME code is working perfect with QT 5.2.1 and MinGW 4.8, but not with the latest version.

    So again, i did send him the QT 5.2.1 MinGW 4.8 dll's and exe, no issues.


  • Lifetime Qt Champion

    @Loc888

    @aha_1980 Listen, this is what your QT team this put it to the package

    As I'm not working for the Qt company, I can't comment on that. But as you are having problems, this might be relevant.


  • Lifetime Qt Champion

    @Loc888

    why is it working for me, why is it working with Qt 5.2.1, and why is NOT working with qt 5.9.8 on my friend's PC.

    You would need to share compileable code that demonstrates the problem if you want us to be able to help you.



  • @aha_1980 There is no way i will send the whole source of the software, i can just send the test project. I am gonna create it now.


  • Lifetime Qt Champion

    @Loc888
    Super that is exactly what @aha_1980 asked for. :)



  • @aha_1980 There you go, this is the link:
    http://www.mediafire.com/file/7me3ya2tkrr9pto/Error.zip/file

    There is Qt 5.2.1 DLL's and exe, and also Qt 5.9.8. The code also is there.
    If you ask me why did i use Connect() in constructor, and in Connect use the real function is because i had a lot of trouble in the past by putting the connections directly in constructor, and i found this simple trick fixed it.

    Ps. Those are the errors i get using Qt 5.9.8:

    C: /Programs/Programming/QT/Qt5.9.8/5.9.8/mingw53_32/mkspecs/features/toolchain.prf (69): system (execute) requires one or two arguments.
    Project ERROR: Can not run compiler 'g ++'. Output:

    ===================
    Maybe you forgot to setup the environment?
    Error parsing C file: /Users/2017/Documents/Qt_Projects/Buttons_test/Buttons_Test/Buttons_Test.pro. Processing interrupted.
    Warnings when parsing information qmltypes in C: /Programs/Programming/QT/Qt5.9.8/5.9.8/mingw53_32/imports:
    1:24: Reading only version 1.1 parts.
    10: 5: Only the definition of a Component or ModuleApi object was expected.


  • Lifetime Qt Champion

    @Loc888

    I've tested your source on Linux, as I don't have Windows at home.

    Your example worked fine, but honestly, I think it is much too complicated.

    I've uploaded a simplified example here: https://filebin.net/x6cg9wnbwjvtt2nb

    Maybe you can try that on Windows and report if it works?

    Ps. Those are the errors i get using Qt 5.9.8:
    C: /Programs/Programming/QT/Qt5.9.8/5.9.8/mingw53_32/mkspecs/features/toolchain.prf (69): system (execute) requires one or two arguments.
    Project ERROR: Can not run compiler 'g ++'. Output:

    That does not look related to your code, but more like a general problem. You should probably create a new thread for that.


  • Qt Champions 2019

    @Loc888 said in Qt 5.9.8 errors with timers and buttons:

    The correct question should be, why is it working for me

    If you want us to take a look into your code you should make it readable for others... and using java-style is definitely very uncomfortable to read for a C++ programmer... :)

    From my pov it looks like a cpu problem - you're updating the label (and you internal variables) every 1ms for no reason.



  • @Christian-Ehrlicher Man, IF THIS is unreadable code, then look at the circus aka STD lib, and other junk, then you will see truly a not readable code. Yes, i know their code is not for read etc, but compare it.

    You said i am updating it for no reason? It's a stopwatch.. Not a finger version of a counter..


  • Qt Champions 2019

    @Loc888 said in Qt 5.9.8 errors with timers and buttons:

    It's a stopwatch.. Not a finger version of a counter..

    So you tell me that you can read all with 1000Hz ? Ok - I'm out ...

    And I think you're also confused by your style:

    if(this->started == false){this->started = false;}
    else if(this->started == true){this->started = true;}
    


  • @Christian-Ehrlicher
    Actually my reflex is good, but i don't read the whole 1000. What you are doing, you are saying i should put what? Value of 50? But i can tell you something, if i spit in my eye, and run that timer with a value of 50ms, i can guarantee you i see the difference, i know because i did. It just looks stupid.

    Ps. That thing you show i used it to fix one issue, and i left it because it's useful in one action. Same thing with connect from Connect and connect, there was an error.... Call your Qt friends and tell them to fix it, then i will not have to lose time, because that both weird codes fixed the issues.

    Ps2. I tested it with value of 50, it looks like retarded finger counter, 20 a little better, but the last number never moves, by 5 i can see clearly the step is by 5, only value of 1deos the job. If someone laugh at me, i will record you a video of it and show you.


  • Lifetime Qt Champion

    Hi @Loc888,

    Ps. That thing you show i used it to fix one issue,

    If you are talking about that one:

    if(this->started == false){this->started = false;}
    else if(this->started == true){this->started = true;}

    then no, that fixes nothing.

    Please try my code and tell us if it works.

    Same thing with connect from Connect and connect, there was an error....

    Which error are you talking about?



  • @aha_1980 I did play a little bit with my Qt, try to add / delete the versions, i did send it to my friend, and now he told me it's working perfectly.... I did change NOTHING, except i did add some qt versions to creator 5.2.1, then delete them, change some compile settings and then make the same i used.
    Both the tests and real softwares works, i don't know what the problem was then.

    ps. I talked with my fiend. What he told me, he downloaded the old versions, before i did any changes in Qt and re-compile the software, and they works both now.
    My friend has a big mess and junk on his pc, by accident he did install something like regCleaner, after we did the tests. That cleaner runs from nowhere, do a scan, mess up his system, and he had to delete some softwares to get it on the point. We did the tests before that thing was on his PC.

    After he did it, all the software started to work. Also, his UI in windows 10 was messed up ,in my software too, but it happened after we tested it, and also before the regCleaner mess up his performance, those buttons was not working, after it they started. So, whos fault was it then?



  • @aha_1980 About that connect error, i don't remember exactly, but it was something like i changed the style sheet in the windows constructor, then use the resize event and connect, and the performance was horrible. I just move the code from there, and put into a sub-function with the same code, and it helped.


Log in to reply