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. QTableWidget in a QTreeWidget
QtWS25 Last Chance

QTableWidget in a QTreeWidget

Scheduled Pinned Locked Moved General and Desktop
15 Posts 4 Posters 10.1k Views
  • 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
    silver356
    wrote on last edited by
    #1

    Hi everybody,
    I have a basic QTreeWidget with two columns and i try to add a QTableWidget in the second one using a QTreeWidgetItem and the setItemWidget function.
    If i display anything but a QTableWidget i have no issue but with a table i have a weird flickering effect when i move my mouse over the QTreeWidgetItem its background is often paint over the table and i don't know why :(
    Any idea ? Thanks

    !http://img696.imageshack.us/img696/2514/treewidget.jpg(My QTreeWidget containing a QTableWidget)!

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

      I'd recommend you check out the offer from "ICS":http://www.ics.com/products/qt/qicstable/ or from "DevMachines":http://www.devmachines.com/qtitandatagrid-overview.html as they already provide such things, if I remember correctly. Doing this yourself based on Qts item views is going to be hard.

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

        I am sorry but ... is it a joke ? :p
        It is just a very basic table in a very basic tree, i guess it's a Qt supported feature no ?
        I don't want to do anything complicated with it, just inserting some numbers.
        Thank you for taking the time to answer me

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Sam
          wrote on last edited by
          #4

          check "this":http://qt-project.org/forums/viewthread/16673/ and "this":http://qt-project.org/forums/viewthread/16837/

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

            [quote author="silver356" date="1343299755"]I am sorry but ... is it a joke ? :p
            It is just a very basic table in a very basic tree, i guess it's a Qt supported feature no ?
            I don't want to do anything complicated with it, just inserting some numbers.
            Thank you for taking the time to answer me[/quote]

            No jokes. Putting widgets inside item vies (and that is what you do, even if the widget is yet another item view), is not trivial. Unless a standard tree is enough for you?

            1 Reply Last reply
            0
            • S Offline
              S Offline
              silver356
              wrote on last edited by
              #6

              Interesting, what do you mean about standard tree ?

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

                A tree like [[doc:QTreeView]] provides you.

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

                  Oh ok i did not know that a QTreeView was more "standard" than a QTreeWidget i though it was the opposite. So you think using this kind of tree will solve my problem ? I just need to put some text and widgets in the tree.
                  Thank you !

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

                    The need to put widgets in the tree is the problem. That is going to be hard to do well and make perform well. Note that QTreeView is the base class of QTreeWidget. QTreeWidget just adds a buid-in model.

                    So no, QTreeView will not help you do that, even though there is the setIndexWidget method in [[doc:QAbstractItemView]]. That might work for you, but it is not what I call model-view programming.

                    1 Reply Last reply
                    0
                    • K Offline
                      K Offline
                      KA51O
                      wrote on last edited by
                      #10

                      [quote author="silver356" date="1343293698"]Hi everybody,
                      If i display anything but a QTableWidget i have no issue but with a table i have a weird flickering effect when i move my mouse over the QTreeWidgetItem its background is often paint over the table and i don't know why :(
                      [/quote]
                      Back to the initial problem.
                      The flickering might be caused by the standard style settings for the treeview. Try to change the QStyleSheet for your treeview (especially the setting for QTreeView::item:hover).
                      Have a look at "this example":http://qt-project.org/doc/qt-4.8/stylesheet-examples.html#customizing-qtreeview. Maybe if you change the setting for QTreeView::item:hover to nothing, or something different then the standard setting, this might solve the flickering problem.

                      1 Reply Last reply
                      0
                      • S Offline
                        S Offline
                        silver356
                        wrote on last edited by
                        #11

                        Thank you but it does not seem to work :/

                        One weird thing is that when i manually change something in my table (add a value for instance), it draws correctly untill the table release !

                        1 Reply Last reply
                        0
                        • K Offline
                          K Offline
                          KA51O
                          wrote on last edited by
                          #12

                          Sorry it didn't help. But as Andre already mentioned doing a Widget in a Table- Tree- or Whatever-View is not as trivial as it might seem at first glance.
                          = /

                          1 Reply Last reply
                          0
                          • S Offline
                            S Offline
                            silver356
                            wrote on last edited by
                            #13

                            Ok thank you both for your very useful help. I think i will try to handle a hierarchy directly through a table i suppose it will avoid those kind of bugs, no ?

                            1 Reply Last reply
                            0
                            • S Offline
                              S Offline
                              silver356
                              wrote on last edited by
                              #14

                              Do you know how the Property Editor in QtDesigner is done ? What kind of container is it ? Its cell seems to be able to contain QWidget.

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

                                I'd suggest you get yourself the sources for QtDesigner, and have a look. The widgets it contains are the same widgets any item view can contain: editors for the items you're editing. That's why you first have to start an edit before you can even check or uncheck a checkbox in that editor, or before you can change an integer.

                                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