PDA

View Full Version : TextEdit in QDialog not accepting data



nbkhwjm
1st October 2008, 22:25
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



#include "extlogwindow.h"
#include "ui_extlogwindow.h"
#include <QDebug>
#include <QSettings>


ExtLogWindow::ExtLogWindow(QWidget *parent) : QDialog(parent)
{

ui.setupUi(this);
// THIS WORKS OK
ui.logWindowTextEdit->setText(tr("this is text"));
// ABOVE WORKS OK
qDebug() << "This is logwindow.cpp";

}

ExtLogWindow::~ExtLogWindow()
{

}

void ExtLogWindow::updateLogWindow(QString &entry)
{

qDebug() << "Logwindow.cpp Logentry" << entry;
// THESE DO NOT WRITE DATA
ui.logWindowTextEdit->setText(tr("this is text #2"));
ui.logWindowTextEdit->append(tr("TTT%1").arg(entry));
// ABOVE DO NOT WORK

}


extlogwindow.h


#include "extlogwindow.h"
#include "ui_extlogwindow.h"
#include <QDebug>
#include <QSettings>
#include <QTextEdit>


ExtLogWindow::ExtLogWindow(QWidget *parent) : QDialog(parent)
{

ui.setupUi(this);
// THIS WORKS OK
ui.logWindowTextEdit->setText(tr("This entry is from the top"));
// ABOVE WORKS OK
qDebug() << "This is logwindow.cpp";

}

ExtLogWindow::~ExtLogWindow()
{

}

void ExtLogWindow::updateLogWindow(QString &entry)
{

qDebug() << "Logwindow.cpp Logentry" << entry;

// THIS DOES NOT WRITE DATA
ui.logWindowTextEdit->append(tr("LOG: %1").arg(entry));
}


The code produces the following on the command line: When I call:
Where "entry" = "test"


ExtLogWindow logger(this);
logger.updateLogWindow(entry);


Command line output


This is logwindow.cpp
Logwindow.cpp Logentry "This entry is from the top"
Logwindow.cpp Logentry "test"


The following shows up in Texedit window


This entry is from the top


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?

spirit
1st October 2008, 22:50
try to add data like this


...
ui.logWindowTextEdit->textCursor().insertText(entry);
...

nbkhwjm
1st October 2008, 22:59
Nope


void ExtLogWindow::updateLogWindow(QString &entry)
{
qDebug() << "Logwindow.cpp Logentry" << entry;
// THESE DO NOT WRITE DATA
ui.logWindowTextEdit->textCursor().insertText(entry);
ui.logWindowTextEdit->setText(tr("Inside the function\n"));
ui.logWindowTextEdit->append(tr("From the other class %1\n").arg(entry));
// ABOVE DO NOT WORK

}

Junior
2nd October 2008, 03:53
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