Skip to content
  • 0 Votes
    1 Posts
    258 Views
    No one has replied
  • 0 Votes
    17 Posts
    1k Views
    haykarmeniH

    thank you, @eyllanesc, now it works as I expect...thank you very much for so much assistance and readiness :)

  • 0 Votes
    5 Posts
    882 Views
    Kent-DorfmanK

    @JKSH said in How do I append characters of a QString to another QString in a neat way?:

    Anyway, you could simplify the whole thing:
    QDateTime now = QDateTime::currentDateTime();

    QString yyyy = now.toString("yyyy");
    QString MM = now.toString("MM");
    QString dd = now.toString("dd");
    QString HH = now.toString("HH");
    QString mm = now.toString("mm");
    QString ss = now.toString("ss");

    This is ideally the best general solution, IMHO

  • 0 Votes
    5 Posts
    1k Views
    S

    If you need this for just measuring the performance of your application, maybe you should use the QML Profiler instead http://doc.qt.io/qtcreator/creator-qml-performance-monitor.html

  • 0 Votes
    1 Posts
    745 Views
    No one has replied
  • 0 Votes
    3 Posts
    2k Views
    Ramkumar RammohanR

    @ekkescorner Thank you.

  • 0 Votes
    2 Posts
    695 Views
    SGaistS

    Hi,

    How is that related to Qt ?

  • How to localtime get?

    Unsolved General and Desktop
    3
    0 Votes
    3 Posts
    1k Views
    F

    @jsulm

    QDateTime::currentDateTime is SystemTime

  • 0 Votes
    9 Posts
    3k Views
    L

    @mrjj
    sorry, okay im now goign to SOLVED this thread thanks @SGaist @mrjj

  • 0 Votes
    6 Posts
    2k Views
    SGaistS

    I'd say: benchmark it, so you'll know how much time it takes to do the match. Don't forget to load several dictionaries to match real-life setup

  • 0 Votes
    4 Posts
    2k Views
    S

    I would suggest taking a look at QElapsedTimer. This class allows you to start a "count up" timer.

    One of the methods of the class is elapsed() which returns the number of milliseconds since the timer was started.

    By knowing how long you want to allow (total time perhaps) and using an elapsed timer with elapsed() the difference between the two will be the remaining time, in milliseconds.

    To convert it to a nice human readable form there are lots of ways but you could simply code up (not the prettiest code, downloaded from a stack overflow post):

    QString ConvertMStoHumanTime( qint64 ms, bool showDays, bool showMS ) { QString Result; double interval; qint64 intval; // Days interval = 24.0 * 60.0 * 60.0 * 1000.0; intval = (qint64)trunc((double)ms / interval); if( intval<0 ) intval = 0; ms -= (qint64)trunc(intval * interval); qint32 days = intval; // Hours interval = 60.0 * 60.0 * 1000.0; intval = (qint64)trunc((double)ms / interval); if( intval<0 ) intval = 0; ms -= (qint64)trunc(intval * interval); qint32 hours = intval; // Minutes interval = 60.0 * 1000.0; intval = (qint64)trunc((double)ms / interval); if( intval<0 ) intval = 0; ms -= (qint64)trunc(intval * interval); qint32 minutes = intval; // Seconds interval = 1000.0; intval = (qint64)trunc((double)ms / interval); if( intval<0 ) intval = 0; ms -= (qint64)trunc(intval * interval); qint32 seconds = intval; // Whatever is left over is milliseconds char buffer[25]; memset( buffer, 0, 25 ); if( showDays ) { if( days<10 ) sprintf_s( buffer, "%d", days ); Result.append( QString("%1d ").arg(buffer) ); } if( hours<10 ) sprintf_s( buffer, "0%d", hours ); else sprintf_s( buffer, "%d", hours ); Result.append( QString("%1:").arg(buffer) ); if( minutes<10 ) sprintf_s( buffer, "0%d", minutes ); else sprintf_s( buffer, "%d", minutes ); Result.append( QString("%1:").arg(buffer) ); if( seconds<10 ) sprintf_s( buffer, "0%d", seconds ); else sprintf_s( buffer, "%d", seconds ); Result.append( QString("%1").arg(buffer) ); if( showMS ) { if( ms<10 ) sprintf_s( buffer, "00%d", ms ); else if( ms<100 ) sprintf_s( buffer, "0%d", ms ); else sprintf_s( buffer, "%d", ms ); Result.append( QString(".%1").arg(buffer) ); } return Result; }