PDA

View Full Version : Complex Custom Widget with QTextEdit (How would you do this?)



binduschen
14th June 2010, 17:48
Hello,

imagine your task is to implement some fancy todo app like "Things" from CulturedCode (http://culturedcode.com/things/). Now consider this image of Things: http://culturedcode.com/styles_2.5/images/screenshot_things_big5.jpg

How would you implement the central part of the main window, the task list? What would be your approach? (Don't consider the tag bar at top, the tool bar at the bottom and the panel on the left)

Here are some hints:

Yes, it has to look nice! (so no standard widget appearance)
Clicking a task expands it to an task editor (as you can see in the middle of the screenshot)
Between the tasks could be some separators (as text, if you sort/group your tasks)
It has to be fast, the tasklist could containt thousands of entries


Apparently you have to create a custom widget or several custom widgets:

Approach #1: One big custom widget (do _everything_ on your own)
Approach #3: One custom widget composed of standard widgets (using stylesheets?)
Approach #3: One custom widget composed of other custom widgets
Approach #3.1: Using layout managers?
Approach #3.2: ...or Model/View-Framework (implement QAbstractListModel, some delegates and a view)

Especially I'm interested in implementing this task editor (task can be expanded to edit the tags, due schedule, notes...). The user has the possibility to enter some lines for a task, especially rich text is important. Sounds like a widget composed of others with a layout manager? Or is there another way to embed a QTextEdit in your own widget (which has to paint his own parts, too)?!

So to sum up:

1) What is your general approach for the whole tasklist?
2) What is your approach for the task editor?

I'm interested in the structure and the reasoning ("This could be a custom widget. (then describe 'this'). Then you can compose these ...that's a nice approach because...").

Thank you very very much,
binduschen

P.S.: My first post, yeah! :)

tbscope
14th June 2010, 18:17
Approach #3.2: ...or Model/View-Framework (implement QAbstractListModel, some delegates and a view)

Looking at the screenshot, the model/view pattern is the way to go.

The custom look can be done via a delegate.
The model is very easy, this can even be a standard item model.
The view itself might need some subclassing though.

But there's another nice model/view pattern in Qt. QGraphicsView.
Using a QGraphicsView might make it considerable more easy to do the painting.

So my first choice would be a QGraphicsView.
If, however, you do need to share the data with other views, I would go for the item views which will be a bit more work.

binduschen
17th June 2010, 21:24
Hello,

thank you very much. Anybody an idea for the text widget?

Best regards!