A
A
Artem2014-01-14 11:47:33
Qt
Artem, 2014-01-14 11:47:33

Creating an Open Documents Widget in Qt?

Hello everyone, I am making an xml text editor on Qt with widgets.
There was a necessity to make the mechanism of open documents as in QtCreator...
Ie . you open some project file, its name is added to the widget of open documents, it opens in the editor. After opening the next document, the same thing happens (a new file name is added to the list of widgets). If we made changes in the open document 1 and switched to 2, all the changes made remain and when returning to document 1, everything remains in its place as it was before the transition (to 2).
I did this:
-Inherited the widget from QListWidget.
-Added QMap attribute
-When a file is opened, a signal with its full name is sent, in my widget I process it with a slot in which I open the file, create a new QListWidgetItem (with the name of the open file), allocate memory for the entire read file in *QTextDocument, save this pair of pointers in a QMap .
Everything seems to be working... but perhaps there is some more elegant template for such a solution?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lolshto, 2014-01-15
@Lol4t0

You need to separate logic and presentation. Look towards MVC any. And I'm not talking so much about Qt models, but about the concept as a whole.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question