Results 1 to 14 of 14

Thread: QListView for "console window"?

  1. #1
    Join Date
    Oct 2007
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default QListView for "console window"?

    Hello again,

    i'm working on a simple dialog window that will use QListView (this is my first idea) for "printing" debug messages. Is this the right approach?
    I was searching the net if someone already faced this kind of problem in Qt but i haven't found anything. I'm working on a socketServer which prints debug info to a file but i also want these info in a dialog window. Is my idea correct and good (using my own ListView with subclassing QListView, QStringList and QStringListModel) or does anybody have a better idea?

    Thank you all

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

    Default Re: QListView for "console window"?

    Quote Originally Posted by bkastel1 View Post
    i'm working on a simple dialog window that will use QListView (this is my first idea) for "printing" debug messages. Is this the right approach?
    It depends. QTextBrowser seems a straightforward candidate, but you might have some special requirements... Then QListView might become a good candidate as well...

  3. The following user says thank you to wysota for this useful post:

    bkastel1 (21st November 2007)

  4. #3
    Join Date
    Oct 2007
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QListView for "console window"?

    Well, requirements are that text can be of different color for different messages (warnings, error, information). The only thing i'm wondering is should i deside to have a fixed number or lines that can be written or not (i think that this is the smart thing to do because i still have a log file where everything is saved). I will check the QTextBrowser and then a decision has to be made

    Thank you and if someone has any additional tips...

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

    Default Re: QListView for "console window"?

    Quote Originally Posted by bkastel1 View Post
    Well, requirements are that text can be of different color for different messages (warnings, error, information).
    That's not a problem for the text browser.

  6. #5
    Join Date
    Oct 2007
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QListView for "console window"?

    Well, i think that we have a winner

    thank you

  7. #6
    Join Date
    Oct 2007
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QListView for "console window"?

    One question regarding QTextBrowser: is there a possibility to set the maximum line count - let's say that when this number is reached first lines are erassed so than new lines can be written?

    Thank you

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

    Default Re: QListView for "console window"?

    I'm not sure, in Qt3 you could do that. But you can always monitor the size of the displayed document and removes lines from the beginning of the document when it grows too large.

  9. #8
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    6,264
    Thanks
    36
    Thanked 1,519 Times in 1,389 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows Symbian S60 Maemo/MeeGo

    Default Re: QListView for "console window"?

    From QTextEdit docs:
    If you want to limit the total number of paragraphs in a QTextEdit, as it is for example open useful in a log viewer, then you can use QTextDocument's maximumBlockCount property for that.
    J-P Nurmi

  10. The following user says thank you to jpn for this useful post:

    bkastel1 (22nd November 2007)

  11. #9
    Join Date
    Oct 2007
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Exclamation Re: QListView for "console window"?

    I know this question will be probalby silly but hot to implement this property to QTextEdit? Should i inherit the QTextEdit and QTextDocument and make my own TextEdit?

    Thank you

  12. #10
    Join Date
    Oct 2007
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QListView for "console window"?

    Is this correct:

    QTextEdit *textEdit = new QTextEdit();
    QTextDocument *document = textEdit->document();

    document->setMaximumBlockCount( n );

    Thanky you

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

    Default Re: QListView for "console window"?

    QTextEdit uses QTextDoument internally. So you can access the widget's document and manipulate it without subclassing anything.

  14. The following user says thank you to wysota for this useful post:

    bkastel1 (23rd November 2007)

  15. #12
    Join Date
    Oct 2007
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QListView for "console window"?

    One interesting remark: when i reach my maximumBlockCount (in my case 1000) i get processor spikes which are as high as 30% every time i add new text (i have a core2duo 2GHz with 2GB RAM). Any idea? i have a multithreaded application.

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

    Default Re: QListView for "console window"?

    The spikes are probably because the document has to go through the whole text and update it, relayout the whole document and do the highlighting (if you use it).

  17. #14
    Join Date
    Oct 2007
    Posts
    18
    Thanks
    6
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Windows

    Default Re: QListView for "console window"?

    Thank you. I will try to find a better way to do this... hopefully

Similar Threads

  1. QListView word wrap
    By serega in forum Qt Programming
    Replies: 17
    Last Post: 30th August 2007, 03:13

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.