How to edit the text in the QListWidget on the run time, by "SINGLE" clicking them?
Code:
{
Q_OBJECT
public:
unsigned int rowCounter;
genericTaskList
(QWidget *parentWidget
) {
setParent (parentWidget);
setFixedSize (445, 445);
defaultText->setFlags (defaultText->flags () | Qt :: ItemIsEditable);
rowCounter = 0;
insertItem (rowCounter, defaultText);
}
public slots:
{
// Returns the current row number.
unsigned int currentRow = row (f);
// Returns the current row text.
QString textOfCurrentRow
= f
->text
();
// The new default row should get inserted if and only if, the last row created has been double clicked and its default text has been changed.
if ((currentRow == rowCounter)
&& (textOfCurrentRow.toStdString () != "Double click here to compose the new task.")
&& (textOfCurrentRow.toStdString () != ""))
{
++rowCounter;
defaultText->setFlags (defaultText->flags () | Qt :: ItemIsEditable);
insertItem (rowCounter, defaultText);
setCurrentRow (rowCounter);
}
else if (textOfCurrentRow.toStdString () == "")
{
takeItem (rowCounter);
defaultText->setFlags (defaultText->flags () | Qt :: ItemIsEditable);
insertItem (rowCounter, defaultText);
setCurrentRow (rowCounter);
}
}
};
The problem here is that I can edit the text if and only if I double click the text. Single click or anything else doesn't work. I tried changing that signal from double click to single click, didn't help.
Please guide - Double clicking all the time is a pain.
Re: How to edit the text in the QListWidget on the run time, by "SINGLE" clicking the
Take a look at setEditTriggers(EditTriggers triggers) method
EditTriggers could be one of the following values:
Code:
QAbstractItemView::SelectedClicked 4 Editing starts when clicking on an already selected item.
QAbstractItemView::EditKeyPressed 8 Editing starts when the platform edit key has been pressed over an item.
QAbstractItemView::AnyKeyPressed 16 Editing starts when any key is pressed over an item.
Re: How to edit the text in the QListWidget on the run time, by "SINGLE" clicking the
I'll try that and get back soon, thanks.