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. QTreeWidgetItemIterator craches.
Forum Updated to NodeBB v4.3 + New Features

QTreeWidgetItemIterator craches.

Scheduled Pinned Locked Moved General and Desktop
12 Posts 4 Posters 4.5k 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.
  • P Offline
    P Offline
    p-himik
    wrote on last edited by
    #3

    Sorry i did not provide this part of code:
    @QTreeWidget* tw;
    // ... initialization of tw ...
    QTreeWidgetItem* item = tw->topLevelItem( 0 )->clone();@

    1 Reply Last reply
    0
    • R Offline
      R Offline
      Rahul Das
      wrote on last edited by
      #4

      @topLevelItem(0)@ returns 0 if the item does not exist. May be its a good idea, you check that before you instanciate.


      Declaration of (Platform) independence.

      1 Reply Last reply
      0
      • P Offline
        P Offline
        p-himik
        wrote on last edited by
        #5

        I did check. More than that, QTreeWidget constructed with "item" as a top level item is displayed normally.

        1 Reply Last reply
        0
        • R Offline
          R Offline
          Rahul Das
          wrote on last edited by
          #6

          I meant a check in code.. @while(QTreeWidgetItem *item = tw->topLevelItem(0)){
          ....
          }@
          [quote author="p-himik" date="1316932916"]I did check. More than that, QTreeWidget constructed with "item" as a top level item is displayed normally.[/quote]

          Am Just curious, is it necessary to create deep copy of the item ?


          Declaration of (Platform) independence.

          1 Reply Last reply
          0
          • P Offline
            P Offline
            p-himik
            wrote on last edited by
            #7

            I think so. I have a parent window with a tree of categories and images and a dialog for adding images to particular category. In this dialog i create QTreeWidget with only categories by cloning QTreeWidget from parent window and removing image items.

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

              Sounds like you need to use real model/view instead of the *widget version... If you go about cloning the tree to display it in another window, you are on the wrong road, if you ask me.

              Instead, you could considder using a QStandardItemModel (API is similar to QTreeWidget and -Item), replace the QTreeWidget with a QTreeView and use a QSortFilterProxyModel to filter out the unwanted items from the model for display on the second window.

              1 Reply Last reply
              0
              • P Offline
                P Offline
                p-himik
                wrote on last edited by
                #9

                I don't know well MVC-part of Qt and this is rather simple application so i decided just to copy items.

                But what about QTreeWidgetItemIterator? Why can it crash when passed parameter is valid?

                1 Reply Last reply
                0
                • R Offline
                  R Offline
                  Rahul Das
                  wrote on last edited by
                  #10

                  one reason could be improper initialization. But you are so sure about it.


                  Declaration of (Platform) independence.

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

                    [quote author="p-himik" date="1316950625"]I don't know well MVC-part of Qt and this is rather simple application so i decided just to copy items.

                    But what about QTreeWidgetItemIterator? Why can it crash when passed parameter is valid?[/quote]

                    If you show us more code, we could perhaps help you, but if we only get one or two lines, we have to gess the rest, which is not very easy.

                    Nokia Certified Qt Specialist.
                    Programming Is Like Sex: One mistake and you have to support it for the rest of your life. (Michael Sinz)

                    1 Reply Last reply
                    0
                    • P Offline
                      P Offline
                      p-himik
                      wrote on last edited by
                      #12

                      Here is a short example: http://dl.dropbox.com/u/26596688/testProject.tar.gz

                      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