I need to show my list from heap.
I am newbie in QT , so I have some questions .
1. What is better to use TreeView or TreeWidget ?
2. How can I control level of selected node ?
3. What is correct way to add items to Tree*** component ?
Thx for answers in advance ?
I came across this post that might help you decide Model-based and item-based? .
In my opinion, if you looking for a more robust and extensible program you might be better off creating your own subclassed model and setting it up with the view.
However if you just want something that you can add a few entries too and be able to link that items index up with with whatever information you want to display, then you could use the widget and add your entries to it.
As you are a beginner, I would suggest that you go the long way around and get your model and view implemented as it would provide you with more experience and will also give you a better understanding of the model view architecture; Which in the long run will allow you to develop better applications.
Related
We need a tree view with File system and check boxes in QT. Is there any way to achieve that?
The tree we need would look something like below:
UPDATE:
I am able to achieve it with subclass of QFileSystemModel. Still have few challenges, but at least subclass is working. Below is the code if anyone needs it. Below is the link to the code -
https://drive.google.com/file/d/1qViZ3iEW2pV2th0jQhzneDL14SEhIgS0/view?usp=sharing
The pending work is to apply a wait cursor (or make treeview uneditable when the check/uncheck is taking place).
PS: It will take a lot of time if root node is checked.
Well, all of that can be achieved with minimal customizations of built-in classes, actually those checkboxes is almost the only thing that has to be done yourself.
QFileSystemModel already provides a proper model for displaying the current filesystem contents, it can be subclassed
As for QML, the best demo is already provided by Qt, check the File System Browser Example. This example uses some deprecaded Qt functionality, but still it shows the basic concept.
The modern techniqes can be also found in the answers to the following question: Qt File Browser based on QML
Hopefully, all that helps you, good luck!
Qtablewidget or Qtableview, which is more proper to make a downloading task list ?
I want to make a downloading task list like this
http://qt-project.org/doc/qt-4.8/images/widgetdelegate.png
the first question is : Qtablewidget or Qtableview, which is more suitable for this job ?
the second question is : how to draw a progress bar in the downloading task list ?
P.S. if chosing Qtablewidget ,I know it has a
QTableWidget.setCellWidget(row, column, widget)
method ,so we can use it to set QprogressBar there .
if chosing Qtableview, we can use Delegate like here
http://qt-project.org/doc/qt-4.8/qabstractitemdelegate.html
(maybe QStyleOptionProgressBarV2 will be more appropriate for the current Qt )
the same question comes here again :which way is more appropriate to do this ?
can anyone give a little example ? cuz the the Qt Torrent Example is so complicated for a newbie like me to learn from it .thanks !!!
Up to me it's very interesting discussion topic. If you look carefully in the documentation you will see that QTableWidget is actually a QTableView with specialised table-oriented functions, default table model, support for widgets in cells out of the box etc. It still has everything which QTableView has if you need some low level customisation. So you really don't have to choose. If you think (and looking on screenshots examples I would agree with that) that QTableWidget can handle most of things you need (like progress bars etc) just take it and go ahead with setCellWidget(...). Since it's QTableView anyway you always have an option to substitute it with your own QTableView implementation with fancy delegates etc.
I think in your scenario you you will use very limited amount of QTableWidget specialised functions, so that shouldn't be any problems at all.
Making it short, on your place I would go for QTableWidget.
I'm a really confused by the different options of drawing in QT. To make it clear, I'm not asking for code. Just I'd be so thankful if someone can shed a light on the best way to implement that. I don't think it's very complicated!
Here is the result that i'm looking for!
The main idea is to have a textinput at the top and a list of suggestion above with matched results.
At the moment, I use a QTreeWidget, and add rows with a QTreeWidgetItem with a QStringList. Obviously it doesn't look like the screenshot :) Should i use a QItemDelegate to handle the drawing? I did some research, but it looks a bit painfull to draw with a QPainter. I thought it would be easier to implement a custom widget and replicate it somehow with maybe a QListView? QListWidget?
Thanks.
You could indeed try to use a QListView to draw your combo, it might be a tad simpler to handle than a QTreeWidget.
Unfortunately, I'm afraid you will have to subclass a QItemDelegate (or some other kind of delegate) to handle a custom display of your data (eg, mixing an icon, a few strings and a date field...).
For the data itself, you may want to consider using a QStandardItemModel. Because you only want to display some data, overwriting the data method should be enough (along the rowCount and columCount methods, of course).
I would like to create an order form for my ASP.net page (I included an example image below). However I don't know how to approach this. I'm assuming the best method would be a gridview but it would involve two levels of grouping. Other requirements would be be to accept a quantity and then calculate the total price. Can anyone point me to some good books or websites that explain creating custom grid views like this (or maybe a better method than using gridview, I'm open to whatever).
I consider myself to be an intermediate programmer in asp.net. I understand a lot of the concepts but I'm trying to learn more practical ways of doing things. Thanks for any knowledge you can provide!
Use a ListView, for two reasons:
It will produce clean markup
Using templates will give you the layout you desire
Here's an example of the type of layout you are after and how to achieve it:
ListView Web Server Control Overview
The best thing for the window I'm designing would be a table with two rows for each element of an array. I'd have one checkbox and two popups in the first row and the second row would be used for text entry. Based on what I understand of a NSTableView is that's not possible. I looked into a NSCollectionView but I don't have any experience with that so my choices are a standard four-column table or tackle a NSCollectionView. Before I do that I wanted to get the opinions of more experienced Cocoa developers.
Thanks
This is possible using either an NSTableview or an NSCollectionview. The NSTableview way would be to subclass NSTextfieldCell ... take a look at ImagePreviewCell.m in apple's PhotoSearch example.
http://developer.apple.com/mac/library/samplecode/PhotoSearch/
The NSCollectionview way would require less code (you can set just about all of it up in IB), but an NSTableView has stuff (like headers etc) than an NSCollectionview doesn't.