Skip to content
  • 0 Votes
    3 Posts
    260 Views
    M

    Hi @JonB ,
    Thank's for your reply .

    I just solved the problem. My goal was to put them in a text file

  • 0 Votes
    6 Posts
    383 Views
    N

    Thanks everyone for your replies.

    @Pl45m4 @mrjj
    What I have in mind is: any event (mouse, key, actions on widgets) that changes the state of the user's data should be captured. Let me give a trivial example (one or more actions implied in each step):

    the user reads x-y data from a file the user manipulates/changes and saves the data based on some provided functionality

    Out of the box, can Qt capture this sequence of actions? As I say in the OP, the intent is to use this log/journal file to debug instead of asking the user to describe the sequence of actions, and also let the user can replay without having to take the actions again.

    Thanks again.

  • 0 Votes
    4 Posts
    799 Views
    G

    I tried some different options, and found a solution:

    void MainWindow::saveSettings() { name = (QCoreApplication::applicationDirPath() +"/logs/"+ui->lineEdit->text() +".txt"); QFile file (name) ; if (newfile == true){ if (file.exists()){ qDebug ()<<"already exists"; NewLog(); timer->stop(); } else { qDebug()<< "Does not exist"; file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); QString c_time = QTime::currentTime().toString(); QString sText =QString::number(update) + ". "+ c_time + ": rpm = "+ rpm + ", load = "+ QString::number(load) + ", " + name1+ " = " + result1 + ", "+ name2+ " = " + result2 + ", " + name3+ " = " + result3 + ", "+ name4+ " = " + result4 + ", " + name5+ " = " + result5 + ", "+ name6+ " = " + result6 + ", " + name7+ " = " + result7 + ", "+ name8+ " = " + result8 + ", " + name9+ " = " + result9 + ", "+ name10+ " = " + result10; ui->label_log->setText(sText); update++; QTextStream out(&file); out << sText + "\n"; file.close(); newfile = false; }}else{ file.open(QIODevice::WriteOnly | QIODevice::Text | QIODevice::Append); QString c_time = QTime::currentTime().toString(); QString sText =QString::number(update) + ". "+ c_time + ": rpm = "+ rpm + ", load = "+ QString::number(load) + ", " + name1+ " = " + result1 + ", "+ name2+ " = " + result2 + ", " + name3+ " = " + result3 + ", "+ name4+ " = " + result4 + ", " + name5+ " = " + result5 + ", "+ name6+ " = " + result6 + ", " + name7+ " = " + result7 + ", "+ name8+ " = " + result8 + ", " + name9+ " = " + result9 + ", "+ name10+ " = " + result10; ui->label_log->setText(sText); update++; QTextStream out(&file); out << sText + "\n"; file.close(); }}

    Maybe it can be easier, but i am still learning. Thanks for your input.
    If you have comments on how to change my code, please tell me.
    (newlog was only to test something else now)

  • 0 Votes
    5 Posts
    3k Views
    SGaistS

    Using QFile::handle

  • Console.log()

    Unsolved General and Desktop
    10
    0 Votes
    10 Posts
    14k Views
    V

    @Anas-A.-Ismail Try to run some simple qml example and put break point and console.log() in event. Its really strange. I don't think we need some kind of config for console.log().

  • 0 Votes
    3 Posts
    1k Views
    sosunS

    @dcape yeah, you're absolutely right. thanks for your efforts. I was thinking about conflicts and checked widthChanged() with auto-completion - this is why i decided not to change the title of js function. Thanks, again ;)

  • 0 Votes
    2 Posts
    4k Views
    JKSHJ

    Hi @AnantAgrawal,

    Just just launch your app from the console. qDebug, qWarning etc. will be printed to the console too (stdout/stderr). Make sure you don't define QT_NO_DEBUG_OUTPUT -- see http://doc.qt.io/qt-5/debug.html for more info.

  • 0 Votes
    2 Posts
    2k Views
    SGaistS

    Hi and welcome to devnet,

    One thing in you code is that in your receive function your are looping over each byte you received and ask to update the widget. What is generally done when handling large amount of data in such small amount is that the processing is done in a different thread. Also the UI update should be batched, there's no real benefit to update your QPlainTextEdit content for every single byte you get.

    Hope it helps