Skip to content
  • 0 Votes
    9 Posts
    917 Views
    GrecKoG

    Nouvelle syntaxe qui a 10 ans pour info ;)

  • 0 Votes
    4 Posts
    359 Views
    BDC_PatrickB

    @jsulm & @J-Hilk

    Thank you so much. You´re my Heroes :D

    Everyday something new to learn :)

  • 0 Votes
    4 Posts
    4k Views
    mrjjM

    @tansgumus
    ah, so the [] part was left and
    it missed the actual body ? ( {})
    Well these things happens :)

  • 0 Votes
    15 Posts
    6k Views
    Petross404_Petros SP

    @mrjj It goes like this :

    Ctor connects a pushbutton click with QtDice::reload which in turn calls QtDice::image_update to animate the gif and after it's finished, show an image.

    I found out what the problem is. QtDice::image_update is called multiple times and therefore it tries to setFileName every time. So a check if fileName() is empty must be done each time before attempting to setFileName.

    void QtDice::image_update(int image_number) { //Make sure we don't constantly re-append a fileName! if(movie->fileName() == "" ) { movie->setFileName(":/images/rolling_infinite.gif"); //If it still is empty print error and exit. Not good at all //TODO wrap the setFileName in some Qt assert to throw an exception if (movie->fileName() == "") { qDebug() << "Error! Couldn't set a fileName to read for the animation"; QApplication::quit(); } } m_ui->label->setMovie(movie); ..... }

    I don't know exactly why this failed ( I mean I could change the fileName as many times as I like), but I checked and rechecked that with this if (movie->fileName() == "" ).... the animation works.

    That could also explain why some (but not all) times the animation played the very first time I push the button (ie called the function) and the second time it stopped. If someone thinks that other reasons come into play, please inform me, I am more than glad to learn.

    For any of you, that is curious what is the code and/or want to c&c, this is the QtDice and this is a screenshot

    Have a nice afternoon!

  • 0 Votes
    4 Posts
    1k Views
    J.HilkJ

    Thanks for the quick reply guys!

    This should answer my questions.

    Also to be more specific, this is part of a setup/initialization-code so this objects and connections are created once during startup, so I should not flood the memory. The main loop of widgets is about 10 in size.

    But I see your point about the switch statement, I could wrap everything up in one connect-statement, but than I would have to create the 3 different Icons berforehand, to refer them correctly in the lambda.

    I may do that, was never a fan of switches in loops myself either.

    Anyway thanks alot.

    Greetings!

  • 0 Votes
    7 Posts
    7k Views
    beeckscheB

    @kshegunov said:

    the way the API is organized is a bit different from QTcpSocket

    You're right. I was also a little bit confused, when i used the QSerialBus module the first time (see my topic https://forum.qt.io/topic/65572/qmodbusmaster-example).

    Like i said, i think you can built your own class by inherit from QModbusDevice to have a synchronous API. The QSerialBus module is marked as technical preview in Qt 5.6, maybe they add some new functions in future releases similar to QTcpSocket like waitForConnected etc.