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::textButton() // slot
{
if (cm::subSelected == -1) {
cr::message("Select an item", "Error", 2);
return;
}
prop = new propForm(this);
}
To copy to clipboard, switch view to plain text mode
void menu::editButton() // slot
{
prop->data->setReadOnly(false);
prop->data->activateWindow();
prop
->data
->moveCursor
(QTextCursor::EndOfBlock);
//end of first line prop->data->ensureCursorVisible();
qDebug() << thisOne;
qDebug() << thisOne->isTopLevel();
qDebug() << thisOne->isActiveWindow();
}
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();
}
To copy to clipboard, switch view to plain text mode
propForm.cpp
data->setGeometry(0, filePath->height(), this->width(), this->height() - filePath->height());
QString fileName
= (cm
::mainItem + "/" + cm
::subItem);
filePath->setText(fileName);
cr::message("Can't open file.", "Error", 2);
return;
}
while ( ! in.atEnd()) data->append(in.readLine());
file.close();
data->setReadOnly(true);
connect (data, SIGNAL(textChanged()), this, SLOT(textChanged()));
this->show();
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();
To copy to clipboard, switch view to plain text mode
void propForm::textChanged() // private slot
{
qDebug() << "text changed";
}
void propForm::textChanged() // private slot
{
qDebug() << "text changed";
}
To copy to clipboard, switch view to plain text mode
Output
menu(0x7ecc78f0)
true
true
text changed
text changed
Output
menu(0x7ecc78f0)
true
true
text changed
text changed
To copy to clipboard, switch view to plain text mode
Bookmarks