Results 1 to 7 of 7

Thread: alt enter simulation in qstring

  1. #1
    Join Date
    Jul 2010
    Posts
    25
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default alt enter simulation in qstring

    Hello,
    I have a log file which has the extension .txt.
    The log file has tab separated values, so it can be opened with excel.
    I append the error found in the QString and then display it in a cell.
    I need to display the errors in the same cell one below another just like it is done with alt+enter.
    Is there any way that I can append alt+enter to the QString itself so that when I open the .txt in excel, the string is represented in the cell one below another.

    Thank you in advance.

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: alt enter simulation in qstring

    Adding a single line feed character will probably work.

  3. #3
    Join Date
    Jul 2010
    Posts
    25
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: alt enter simulation in qstring

    Thanks for the reply, but I already tried appending "\n" to the string and also "\r\n", but that causes the string to be printed in the cell in the next row, not in the same cell.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,014 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: alt enter simulation in qstring

    Format the file as csv and not plain text. Then you'll be able to use csv rules for appending newlines to cell values. Excel will import that without a problem.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  5. #5
    Join Date
    Nov 2010
    Posts
    97
    Thanks
    6
    Thanked 11 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: alt enter simulation in qstring

    Quote Originally Posted by Dilshad View Post
    Hello,
    I have a log file which has the extension .txt.
    The log file has tab separated values, so it can be opened with excel.
    I append the error found in the QString and then display it in a cell.
    I need to display the errors in the same cell one below another just like it is done with alt+enter.
    Is there any way that I can append alt+enter to the QString itself so that when I open the .txt in excel, the string is represented in the cell one below another.

    Thank you in advance.
    I'm 99.999999% sure that excel won't ever respond to anything you might come up with in the way you're expecting. In UI programs like excel, Alt+Enter is not a character code in the string, it's a key code in an event that the UI responds to by moving focus to a different cell (or whatever)--Alt+Enter doesn't even result in a character code at all so even if excell does do it, it does it itself in its own special way. This difference in cell is then saved in some special way by the program. Your best, and probably only bet, is CSV like wysota mentioned or an actual excel file format. The former being almost certainly the easier way.

  6. #6
    Join Date
    Sep 2009
    Location
    UK
    Posts
    2,447
    Thanks
    6
    Thanked 348 Times in 333 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: alt enter simulation in qstring

    I know CSV will work as I've done it before, however it probably will not be what you want because of the limitations of the CSV file format. You can use multiple lines by including a linefeed (0x0A) character in the quoted string for that column, but the column will only be the height of a single line so you will not see this extra data until you manually (in excel) resize that row, or edit the data to automatically resize the row. You can't include this row-height property in the CSV file.

    I would therefore suggest you use XML file format. For example:

    Qt Code:
    1. <?xml version="1.0"?>
    2. <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet"
    3. xmlns:o="urn:schemas-microsoft-com:office:office"
    4. xmlns:x="urn:schemas-microsoft-com:office:excel"
    5. xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet"
    6. xmlns:html="http://www.w3.org/TR/REC-html40">
    7. <DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">
    8. </DocumentProperties>
    9. <OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">
    10. </OfficeDocumentSettings>
    11. <ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">
    12. <ProtectStructure>False</ProtectStructure>
    13. <ProtectWindows>False</ProtectWindows>
    14. </ExcelWorkbook>
    15. <Styles>
    16. <Style ss:ID="Default" ss:Name="Normal">
    17. <Alignment ss:Vertical="Bottom"/>
    18. </Style>
    19. <Style ss:ID="s21">
    20. <Alignment ss:Vertical="Bottom" ss:WrapText="1"/>
    21. </Style>
    22. </Styles>
    23. <Worksheet ss:Name="Book1">
    24. <Table ss:ExpandedColumnCount="5" ss:ExpandedRowCount="1" x:FullColumns="1"
    25. x:FullRows="1">
    26. <Row>
    27. <Cell><Data ss:Type="String">a</Data></Cell>
    28. <Cell><Data ss:Type="String">b</Data></Cell>
    29. <Cell ss:StyleID="s21"><Data ss:Type="String">c
    30. line 2</Data></Cell>
    31. <Cell><Data ss:Type="String">d</Data></Cell>
    32. <Cell><Data ss:Type="String">e</Data></Cell>
    33. </Row>
    34. </Table>
    35. </Worksheet>
    36. </Workbook>
    To copy to clipboard, switch view to plain text mode 

    Note the use of a different style for the cell where you wish to include an embedded linefeed. Without this, the line feed character will be parsed incorrectly and you'll just see a square box.

    EDIT: Hmm, it seems the forum software has converted the "&#10<semicolon>" into an actual line feed. If you wish to try this XML file out, you may wish to change that back, or just download this attachment: Book1.xml
    Last edited by squidge; 28th December 2010 at 18:36.

  7. The following user says thank you to squidge for this useful post:

    Dilshad (29th December 2010)

  8. #7
    Join Date
    Jul 2010
    Posts
    25
    Thanks
    4
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: alt enter simulation in qstring

    Thanks Everyone,
    @squidge I will try the solution. Thanks.

Similar Threads

  1. Multilotek - simulation of lottery game
    By Fazer in forum Qt-based Software
    Replies: 0
    Last Post: 8th September 2009, 14:19
  2. physics simulation
    By scrasun in forum General Programming
    Replies: 6
    Last Post: 11th June 2009, 02:19
  3. Replies: 1
    Last Post: 14th September 2008, 23:05
  4. Replies: 4
    Last Post: 31st January 2008, 20:44
  5. QTimer or recursive calls for simulation?
    By Morea in forum Qt Programming
    Replies: 3
    Last Post: 12th May 2006, 00:19

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.