O'Reilly logo

Qt 5 Projects by Marco Piccolino

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Inserting a character's name into the dialogue script

Once a character's name is in the list, we will want our user to insert it into the list as a dialogue opener by just double-clicking on the character's name.

To retrieve a single item at a specified index from Characters, we can use the already implemented data method. In order to do so, we will first need a pointer to the scriptEditor widget:

// ccscripter/main.cpp...auto scriptEditor = w.ui->scriptEditor;...

Implementing the use case is then as simple as the following:

// ccscripter/main.cpp...if (charactersListView && scriptEditor) {    QObject::connect(charactersListView, &QListView::doubleClicked, [characters, scriptEditor](QModelIndex index) { scriptEditor->append(QString("> %1: ").arg(characters->data(index).toString())); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required