Results 1 to 5 of 5

Thread: Problem creating a QTableWidgetIem

  1. #1
    Join Date
    Sep 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Problem creating a QTableWidgetIem

    Hi everyone. I have been searching on google and couldn't found an answer(Probably I didn't search well)
    I am having troubles creating a QTableWidgetItem
    Qt Code:
    1. QString mes=get_Character(opt);
    2. QTableWidgetItem *item=new QTableWidgetItem(mes,1000);
    3. ui->tableWidget->setItem(i,j,item);
    To copy to clipboard, switch view to plain text mode 

    I supoose the constructor is well done.
    According to this QTableWidgetItem::QTableWidgetItem ( const QString & text, int type = Type
    If nop I miss understood that part.
    Thank you

  2. #2
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Problem creating a QTableWidgetIem

    A type should be handled in a custom subclass I guess?
    What happens if you don't use a custom type?

  3. #3
    Join Date
    Sep 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem creating a QTableWidgetIem

    tbscope
    I don't understand you really.(English is not my native language)
    But the program compiles, but at the moment of running it the program close automatically

  4. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: Problem creating a QTableWidgetIem

    Try this:

    Qt Code:
    1. ui->tableWidget->setRowCount(10);
    2. ui->tableWidget->setColumnCount(5);
    3.  
    4. QTableWidgetItem *newItem = new QTableWidgetItem("Hello world!");
    5. ui->tableWidget->setItem(2, 2, newItem);
    To copy to clipboard, switch view to plain text mode 

    First, set the amount of rows and columns.
    Then construct a new table widget item and add set it in a certain cell.

  5. #5
    Join Date
    Sep 2010
    Posts
    12
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Problem creating a QTableWidgetIem

    I have a QTableWidget created with 8 rows and 15 columns. I created it graphically.
    And this doesn't seems to work
    Qt Code:
    1. QTableWidgetItem *newItem = new QTableWidgetItem("Hello world!");
    2. ui->tableWidget->setItem(2, 2, newItem);
    To copy to clipboard, switch view to plain text mode 

Similar Threads

  1. problem creating a mysql database
    By TonyB in forum Qt Programming
    Replies: 10
    Last Post: 23rd July 2010, 15:39
  2. Problem When Creating my own Slot
    By Fatla in forum Qt Programming
    Replies: 12
    Last Post: 6th June 2008, 14:44
  3. problem creating dom tree
    By dreamer in forum Qt Programming
    Replies: 2
    Last Post: 8th May 2008, 08:12
  4. creating dll problem -> no exports ...
    By vrudolf in forum Qt Programming
    Replies: 2
    Last Post: 30th July 2006, 16:47

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.