Results 1 to 11 of 11

Thread: Connect external widget(slider, linedit) to QTableWidgetItem

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Nov 2010
    Posts
    142
    Thanks
    24
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Connect external widget(slider, linedit) to QTableWidgetItem

    Did you mean this?

    Qt Code:
    1. MyTableItem* MyTable::item ( int row, int column ) const
    2. {
    3. return item ( row, column );
    4. }
    To copy to clipboard, switch view to plain text mode 

    It compiles fine, but I get segmentation fault because of this

    the source code has something like this:
    Qt Code:
    1. return tableItems.value(tableIndex(row, column));
    To copy to clipboard, switch view to plain text mode 

    but i don't know how to transform it to my class

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,394
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Connect external widget(slider, linedit) to QTableWidgetItem

    segmentation fault because of this
    Yes, this is correct behaviour according to the implementation

    Try to imagine what happens when you call
    Qt Code:
    1. item(2,2);
    To copy to clipboard, switch view to plain text mode 
    ...
    ( small hint: item(2,2) => { return item(2,2) => { return item(2,2) => ... } } )
    Calling the same method with the same arguments over and over...

    What you want to do is to call base class implementation of "item" from your class "item" method and convert the result to your datatype. So there are two more questions:
    1) how to call base class implementation from derived class method ?
    2) how to convert from base class pointer to derived class pointer at runtime ?

    Can't help you more with this, because next step is to write ~30 more characters in your "item" implementation Believe me, you'll learn much more by doing this yourself ( there is great, free C++ book available online called "Thinking in C++" )

Similar Threads

  1. Replies: 22
    Last Post: 14th October 2010, 17:44
  2. sync plot grid w/ external scale widget
    By Kevin Ching in forum Qwt
    Replies: 6
    Last Post: 30th September 2010, 17:12
  3. Replies: 2
    Last Post: 21st March 2010, 09:01
  4. Dock widget does not have a size slider
    By rakkar in forum Newbie
    Replies: 3
    Last Post: 9th September 2009, 08:33
  5. Replies: 1
    Last Post: 14th June 2006, 14:36

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Qt is a trademark of The Qt Company.