Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. allign texts in QTextStream
Forum Updated to NodeBB v4.3 + New Features

allign texts in QTextStream

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 385 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ODБOïO Offline
    ODБOïO Offline
    ODБOï
    wrote on last edited by ODБOï
    #1

    Hi, I did this method to log things in my app,

      void logToFile(const int msg,const double frmcpt){
        
                QFile file("Log.txt");
                if (!file.open(QIODevice::WriteOnly | QIODevice::Append)){
                     return;
                }
        
                QTextStream t(&file);
        
                switch (msg) {
                case NEW_CONN   : t << "\n\r Connexion : " << QDateTime::currentDateTime().toString(); break;
                case RECO_FAIL  : t << "\n\r Echéc Connexion : " << QDateTime::currentDateTime().toString(); break;
                
                default: break;
                }
        
                file.close();
            }
    
    

    How can i allign the dates please ?

    raven-worxR 1 Reply Last reply
    0
    • ODБOïO ODБOï

      Hi, I did this method to log things in my app,

        void logToFile(const int msg,const double frmcpt){
          
                  QFile file("Log.txt");
                  if (!file.open(QIODevice::WriteOnly | QIODevice::Append)){
                       return;
                  }
          
                  QTextStream t(&file);
          
                  switch (msg) {
                  case NEW_CONN   : t << "\n\r Connexion : " << QDateTime::currentDateTime().toString(); break;
                  case RECO_FAIL  : t << "\n\r Echéc Connexion : " << QDateTime::currentDateTime().toString(); break;
                  
                  default: break;
                  }
          
                  file.close();
              }
      
      

      How can i allign the dates please ?

      raven-worxR Offline
      raven-worxR Offline
      raven-worx
      Moderators
      wrote on last edited by raven-worx
      #2

      @LeLev
      QTextStream::setFieldWidth()/QTextsTream::setFieldAlignment()

      --- SUPPORT REQUESTS VIA CHAT WILL BE IGNORED ---
      If you have a question please use the forum so others can benefit from the solution in the future

      ODБOïO 1 Reply Last reply
      4
      • raven-worxR raven-worx

        @LeLev
        QTextStream::setFieldWidth()/QTextsTream::setFieldAlignment()

        ODБOïO Offline
        ODБOïO Offline
        ODБOï
        wrote on last edited by
        #3
         QTextStream t(&file);
                    t.setFieldAlignment(QTextStream::AlignLeft);
        
                    int fw = 30;
        
                    switch (msg) {
                    case NEW_CONN   : t << qSetFieldWidth(fw)
                                        << "\n\r Connexion : "
                                        << QDateTime::currentDateTime().toString(); break;
        
                    case RECO_FAIL  : t << qSetFieldWidth(fw)
                                        << "\n\r Echéc Connexion : "
                                        << QDateTime::currentDateTime().toString(); break;
        

        Thx!

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved