Results 1 to 4 of 4

Thread: Extracting text from QTableWidgetItem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2009
    Posts
    25
    Thanks
    7
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Extracting text from QTableWidgetItem

    Hello, all;

    I’d appreciate some assistance in being able to extract text from a QTableWidgetItem. I’ve tried using the .text() command, but I have problems getting the text and passing it along no matter how I declare the object that I use to hold it. The object I seem to be having problems with is “displayText” below: I’ve tried declaring it as a pointer and a non-pointer, and the only way I can get this code to compile is by writing it this way (right now I’m using dummy text to try to get the program to work):

    Qt Code:
    1. QTableWidget *listWidget = new QTableWidget(2,2,this);
    2. QTableWidgetItem *newItem1 = new QTableWidgetItem(tr("Display Text 1"));
    3. listWidget->setItem(0, 0, newItem1);
    4. listWidget->hide();
    5.  
    6. QString displayText;
    7.  
    8. displayText = (*newItem1).text();
    9.  
    10. QLineEdit *textDisplay = new QLineEdit();
    11. textDisplay->setStyleSheet(swQuad2_stylesheet);
    12. textDisplay->setText(displayText);
    13. textDisplay->setReadOnly(true);
    14.  
    15. QVBoxLayout *SWLayout = new QVBoxLayout;
    16. SWLayout->addStretch(1);
    17. SWLayout->addWidget(textDisplay);
    18. SWLayout->addStretch(1);
    To copy to clipboard, switch view to plain text mode 

    However, even though the code does compile, I get the following errors when I run it:

    Could not parse application stylesheet
    Segmentation fault

    Any suggestions? Thanks in advance.
    Last edited by wysota; 31st August 2009 at 21:34. Reason: missing [code] tags

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. QTableWidgetItem Text Editing
    By ToddAtWSU in forum Qt Programming
    Replies: 2
    Last Post: 17th March 2009, 02:23
  3. Extracting text from files (AKA I'm a newbie!)
    By mike phillips in forum Newbie
    Replies: 16
    Last Post: 30th January 2009, 17:27
  4. Setting a highlight text color for QTableWidgetItem
    By Hiba in forum Qt Programming
    Replies: 6
    Last Post: 14th December 2007, 10:51
  5. Auto text select in QTableWidgetItem
    By tstankey in forum Newbie
    Replies: 2
    Last Post: 5th October 2006, 20:40

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
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.