Problem with QTableView and "connect"
-
Hi people,
i have a problem...
I'm using QTableView to have a a table where i'm going to display a columnList like this:@
QTableView* itemView;
QList<QStandardItem*> columnList;
@some of the items of the list are "Checkable".
I have associated an action to these time in this manner:
@
connect(itemView->model(), SIGNAL(itemChanged(QStandardItem*)), this, SLOT(selectedItemsChanged(QStandardItem*)))
@but, i need to understand which is the Item checked by the user, because i have a lots of items in the itemView.
How can i do??
Thanks[EDIT: fixed code formatting, Moved to general forum, Volker]
-
The item that was changed is delivered in the signal's argument and you get it in your slot.
-
Thanks mod...
Sorry my slot is:
@ void MobilePhoneWidget::selectedItemsChanged(QStandardItem*){
@ system ("echo inside");}Can you add the code to use the item changed????
I'm a newbie of this language and i'm sorry if the question if really easy for you.
Thanks
-
This does not make much sense.
The signals that QTableView supports are "documented":http://developer.qt.nokia.com/doc/qt-4.7/qabstractitemview.html#signalSection here. As you see, there is no signal that sends pointers to QStandardItems around. The signal you try to connect to tells you something about the data of the item being changed. However, it's selection status is not part of its data[1].[1] I am working on a design for a new item view framework where it actually_would_ be part of the items' data, but I not sure it will ever see the light of day.
-
Thanks for the answer.
I need to print the data stored in the item that is checked.
When you check the item, i need to print the data.
How can i do if this is not the right solution? -
OK, first of all, do you mean selected or do you really mean checked, as in setting a check box?
The latter is part of the data actually.
-
Sorry i mean checked, because is like a checkbox.
When you check, i need the url that i stored before in the QStandardItem to open a browser session with that url.Really thanks for the answer and sorry.
-
I'm going to show you a screen shot.
In this screenshot,when i check one QStandardItem, i need to open a browser page with the url associated with that item....!http://imageshack.us/photo/my-images/204/editedj.png(screenshot)!
-
[quote author="Sinapse" date="1323347957"]Thanks mod...
Sorry my slot is:
@ void MobilePhoneWidget::selectedItemsChanged(QStandardItem*){
@ system ("echo inside");}Can you add the code to use the item changed????
I'm a newbie of this language and i'm sorry if the question if really easy for you.
Thanks
[/quote]This is less than basic C++ "magic": Give the argument a name and use it. It's an ordinary C++ method.
I suggest you make yourself familiar with the basics of C++ first, e.g. by studying one of the many tutorials out in the net. It won't bring you anywhere without this, Qt C++ cannot be used without that basic C++ skills, sorry...
-
Yes you are right.
Never used c++ in my life.
I came in Irland to make my thesis project and they give me a task in c++ and that i have to finish early.In any cases thanks a lot...
-
You're welcome. Don't feel offended by the comment. It's just common experience, that the learning curve is too steep to start with learning C++ and Qt at the same time. Just play around a bit with plain C++ and add the Qt later on. You can continue using Qt Creator for your exercises, just create a plain C++ project that doesn't use Qt. The new project wizard has this option.
-
Thanks.
I need to use QtCreator because the legacy system was written in QtCreator. But i don't need to to a lot of tasks... So sometimes i'm asking help here. I hope don't waste your time. When you or everyone can't give me an answer just put the references please....Really thanks.
I'm sorry...
Luca -
No problem. Don't hesitate to ask - we seldomly bite :-)