jimbo
18th March 2015, 14:02
Hello,
In the QTextEdit the cursor is positioned at the end of the first line of the text, as its supposed to be.
However, if I then press the backspace key, the textChanged() slot gets called twice.
I don't understand why. Perhaps someone could explain.
With text and punctuation keys, the slot gets called once.
Its not a problem for me, I'd just like to know why.
Thanks in advance.
Regards
void menu::textButton() // slot
{
if (cm::subSelected == -1) {
cr::message("Select an item", "Error", 2);
return;
}
prop = new propForm(this);
}
void menu::editButton() // slot
{
prop->data->setReadOnly(false);
prop->data->activateWindow();
prop->data->moveCursor(QTextCursor::Start);
prop->data->moveCursor(QTextCursor::EndOfBlock); //end of first line
prop->data->ensureCursorVisible();
QWidget *thisOne = QApplication::activeWindow();
qDebug() << thisOne;
qDebug() << thisOne->isTopLevel();
qDebug() << thisOne->isActiveWindow();
}
propForm.cpp
data = new QTextEdit(this);
data->setGeometry(0, filePath->height(), this->width(), this->height() - filePath->height());
QString fileName = (cm::mainItem + "/" + cm::subItem);
filePath->setText(fileName);
QFile file(fileName);
if ( ! (file.open(QIODevice::ReadWrite))) {
cr::message("Can't open file.", "Error", 2);
return;
}
QTextStream in(&file);
while ( ! in.atEnd()) data->append(in.readLine());
file.close();
data->setReadOnly(true);
connect (data, SIGNAL(textChanged()), this, SLOT(textChanged()));
this->show();
void propForm::textChanged() // private slot
{
qDebug() << "text changed";
}
Output
menu(0x7ecc78f0)
true
true
text changed
text changed
In the QTextEdit the cursor is positioned at the end of the first line of the text, as its supposed to be.
However, if I then press the backspace key, the textChanged() slot gets called twice.
I don't understand why. Perhaps someone could explain.
With text and punctuation keys, the slot gets called once.
Its not a problem for me, I'd just like to know why.
Thanks in advance.
Regards
void menu::textButton() // slot
{
if (cm::subSelected == -1) {
cr::message("Select an item", "Error", 2);
return;
}
prop = new propForm(this);
}
void menu::editButton() // slot
{
prop->data->setReadOnly(false);
prop->data->activateWindow();
prop->data->moveCursor(QTextCursor::Start);
prop->data->moveCursor(QTextCursor::EndOfBlock); //end of first line
prop->data->ensureCursorVisible();
QWidget *thisOne = QApplication::activeWindow();
qDebug() << thisOne;
qDebug() << thisOne->isTopLevel();
qDebug() << thisOne->isActiveWindow();
}
propForm.cpp
data = new QTextEdit(this);
data->setGeometry(0, filePath->height(), this->width(), this->height() - filePath->height());
QString fileName = (cm::mainItem + "/" + cm::subItem);
filePath->setText(fileName);
QFile file(fileName);
if ( ! (file.open(QIODevice::ReadWrite))) {
cr::message("Can't open file.", "Error", 2);
return;
}
QTextStream in(&file);
while ( ! in.atEnd()) data->append(in.readLine());
file.close();
data->setReadOnly(true);
connect (data, SIGNAL(textChanged()), this, SLOT(textChanged()));
this->show();
void propForm::textChanged() // private slot
{
qDebug() << "text changed";
}
Output
menu(0x7ecc78f0)
true
true
text changed
text changed