I'm teaching my self Qt; in the same time I don't want to lose my Java skills in Qt. I stacked in some codes to do it in Qt, I tried many times as well as search in the net.
Code # 1
Object[] names = jList1.getSelectedValues();
String msg = "";
for (Object o : names)
msg += o;
Code # 2
DefaultListModel model;
model = new DefaultListModel();
jList1.setModel(model);
Code # 3
if(!jList1.isSelectionEmpty())
I didn't find Empty method :-(
I'm going to do some Qt's video tutorials on youtube, but before that I need to solve the above codes. If any programmer can help I will be thankful;
Thanks in advance
At the end 开发者_高级运维I would like to thanks the experts who are spent thier value times to help others
What you want for code #1 and #3 is the selection model. It does not have an empty method, but hasSelection
aught to do it for you.
As for code #2, you could use the QStandardItemModel. It could be considered the default model if you must, but having a standard model in most cases defeats the purpose of the model-view paradigm (proving a model interface to your actual data). You could also look into the QList
/Tree
/TableWidget
classes, as they come with a model (which QList
/Tree
/TableView
don't).
精彩评论