Results 1 to 4 of 4

Thread: TextEdit in QDialog not accepting data

  1. #1
    Join Date
    Mar 2007
    Posts
    59
    Thanks
    7

    Unhappy TextEdit in QDialog not accepting data

    now i been looking at this for two hours, hopefully someone will make me look bad here.

    I have a mainwindow that opens a Qdialog called ExtLogWindow, the window opens fine and I'm happy there.

    I send logging events to a function in ExtLogWindow that *should* write them to the Textedit window.

    extlogwindow.cpp

    Qt Code:
    1. #include "extlogwindow.h"
    2. #include "ui_extlogwindow.h"
    3. #include <QDebug>
    4. #include <QSettings>
    5.  
    6.  
    7. ExtLogWindow::ExtLogWindow(QWidget *parent) : QDialog(parent)
    8. {
    9.  
    10. ui.setupUi(this);
    11. // THIS WORKS OK
    12. ui.logWindowTextEdit->setText(tr("this is text"));
    13. // ABOVE WORKS OK
    14. qDebug() << "This is logwindow.cpp";
    15.  
    16. }
    17.  
    18. ExtLogWindow::~ExtLogWindow()
    19. {
    20.  
    21. }
    22.  
    23. void ExtLogWindow::updateLogWindow(QString &entry)
    24. {
    25.  
    26. qDebug() << "Logwindow.cpp Logentry" << entry;
    27. // THESE DO NOT WRITE DATA
    28. ui.logWindowTextEdit->setText(tr("this is text #2"));
    29. ui.logWindowTextEdit->append(tr("TTT%1").arg(entry));
    30. // ABOVE DO NOT WORK
    31.  
    32. }
    To copy to clipboard, switch view to plain text mode 

    extlogwindow.h
    Qt Code:
    1. #include "extlogwindow.h"
    2. #include "ui_extlogwindow.h"
    3. #include <QDebug>
    4. #include <QSettings>
    5. #include <QTextEdit>
    6.  
    7.  
    8. ExtLogWindow::ExtLogWindow(QWidget *parent) : QDialog(parent)
    9. {
    10.  
    11. ui.setupUi(this);
    12. // THIS WORKS OK
    13. ui.logWindowTextEdit->setText(tr("This entry is from the top"));
    14. // ABOVE WORKS OK
    15. qDebug() << "This is logwindow.cpp";
    16.  
    17. }
    18.  
    19. ExtLogWindow::~ExtLogWindow()
    20. {
    21.  
    22. }
    23.  
    24. void ExtLogWindow::updateLogWindow(QString &entry)
    25. {
    26.  
    27. qDebug() << "Logwindow.cpp Logentry" << entry;
    28.  
    29. // THIS DOES NOT WRITE DATA
    30. ui.logWindowTextEdit->append(tr("LOG: %1").arg(entry));
    31. }
    To copy to clipboard, switch view to plain text mode 

    The code produces the following on the command line: When I call:
    Where "entry" = "test"
    Qt Code:
    1. ExtLogWindow logger(this);
    2. logger.updateLogWindow(entry);
    To copy to clipboard, switch view to plain text mode 

    Command line output
    Qt Code:
    1. This is logwindow.cpp
    2. Logwindow.cpp Logentry "This entry is from the top"
    3. Logwindow.cpp Logentry "test"
    To copy to clipboard, switch view to plain text mode 

    The following shows up in Texedit window
    Qt Code:
    1. This entry is from the top
    To copy to clipboard, switch view to plain text mode 

    Any ideas? The variable "entry" is seen by the function or i would not get the command line output of "logwindow.cpp logentry "test"" Why does it not populate the data from the other function to QTextEdit?
    Last edited by nbkhwjm; 1st October 2008 at 22:26. Reason: spelling error

  2. #2
    Join Date
    Aug 2008
    Location
    Ukraine, Krivoy Rog
    Posts
    1,963
    Thanked 370 Times in 336 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: TextEdit in QDialog not accepting data

    try to add data like this
    Qt Code:
    1. ...
    2. ui.logWindowTextEdit->textCursor().insertText(entry);
    3. ...
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Mar 2007
    Posts
    59
    Thanks
    7

    Default Re: TextEdit in QDialog not accepting data

    Nope

    Qt Code:
    1. void ExtLogWindow::updateLogWindow(QString &entry)
    2. {
    3. qDebug() << "Logwindow.cpp Logentry" << entry;
    4. // THESE DO NOT WRITE DATA
    5. ui.logWindowTextEdit->textCursor().insertText(entry);
    6. ui.logWindowTextEdit->setText(tr("Inside the function\n"));
    7. ui.logWindowTextEdit->append(tr("From the other class %1\n").arg(entry));
    8. // ABOVE DO NOT WORK
    9.  
    10. }
    To copy to clipboard, switch view to plain text mode 

  4. #4
    Join Date
    Dec 2006
    Location
    San Antonio, TX
    Posts
    9
    Thanked 2 Times in 2 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: TextEdit in QDialog not accepting data

    nbkhwjm,

    I created an example based on what you described below in what you are doing and I couldn't replicate the problem your experiencing. So I'm going to pass on the example I was working with so you can compare and see if maybe something sticks out at you that could be the problem child.

    The example has a Mainwindow with log entry area, and you can access the textdialog (logger) for viewing from View menu. Hopefully it is close to what you are dealing with to find the problem.

    Junior
    Attached Files Attached Files

Similar Threads

  1. Clearing of data in TextEdit
    By keshab in forum Newbie
    Replies: 3
    Last Post: 15th December 2006, 11:29
  2. speed of setdata - lots of items in treeview
    By Big Duck in forum Qt Programming
    Replies: 4
    Last Post: 6th July 2006, 12:53

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.