Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Problem with QTableView and "connect"
Forum Updated to NodeBB v4.3 + New Features

Problem with QTableView and "connect"

Scheduled Pinned Locked Moved General and Desktop
13 Posts 3 Posters 4.1k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sinapse
    wrote on last edited by
    #1

    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]

    1 Reply Last reply
    0
    • G Offline
      G Offline
      goetz
      wrote on last edited by
      #2

      The item that was changed is delivered in the signal's argument and you get it in your slot.

      http://www.catb.org/~esr/faqs/smart-questions.html

      1 Reply Last reply
      0
      • S Offline
        S Offline
        Sinapse
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • A Offline
          A Offline
          andre
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          • S Offline
            S Offline
            Sinapse
            wrote on last edited by
            #5

            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?

            1 Reply Last reply
            0
            • A Offline
              A Offline
              andre
              wrote on last edited by
              #6

              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.

              1 Reply Last reply
              0
              • S Offline
                S Offline
                Sinapse
                wrote on last edited by
                #7

                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.

                1 Reply Last reply
                0
                • S Offline
                  S Offline
                  Sinapse
                  wrote on last edited by
                  #8

                  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)!

                  1 Reply Last reply
                  0
                  • G Offline
                    G Offline
                    goetz
                    wrote on last edited by
                    #9

                    [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...

                    http://www.catb.org/~esr/faqs/smart-questions.html

                    1 Reply Last reply
                    0
                    • S Offline
                      S Offline
                      Sinapse
                      wrote on last edited by
                      #10

                      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...

                      1 Reply Last reply
                      0
                      • G Offline
                        G Offline
                        goetz
                        wrote on last edited by
                        #11

                        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.

                        http://www.catb.org/~esr/faqs/smart-questions.html

                        1 Reply Last reply
                        0
                        • S Offline
                          S Offline
                          Sinapse
                          wrote on last edited by
                          #12

                          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

                          1 Reply Last reply
                          0
                          • G Offline
                            G Offline
                            goetz
                            wrote on last edited by
                            #13

                            No problem. Don't hesitate to ask - we seldomly bite :-)

                            http://www.catb.org/~esr/faqs/smart-questions.html

                            1 Reply Last reply
                            0

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved