Results 1 to 3 of 3

Thread: how to add a tagline to QListWidet addItem() along with the data?

  1. #1
    Join Date
    Jan 2016
    Posts
    22
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Question how to add a tagline to QListWidet addItem() along with the data?

    Hello everyone,

    I am working with QListWidget and I am supposed to pass a string to my ListWidget using addItem.


    I have a line ui->listwidget->addItem(QString::fromstdString(s2));

    where as S2 consists of some values like 1 , 2 , 3 ........

    Now I want my output on the screen as


    The Output data:: 1
    The Output data:: 2
    ........



    How can I pass the string "The output data" to ListWidget.


    It would be great help if someone can help me out.

    Thank you

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,420
    Thanks
    37
    Thanked 1,545 Times in 1,495 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: how to add a tagline to QListWidet addItem() along with the data?

    QString has a "+" operator that allows you to concatenate string into a new string.

    Alternatively you can use QString::arg() to replace a placeholder in the fixed string with the runtime value from s2.

    Cheers,
    _

  3. #3
    Join Date
    Jan 2016
    Posts
    22
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: how to add a tagline to QListWidet addItem() along with the data?

    It worked Thank you very much

Similar Threads

  1. [ASK] QGraphicsScene->addItem() crash
    By radith in forum Qt Programming
    Replies: 1
    Last Post: 20th November 2014, 01:05
  2. Replies: 5
    Last Post: 4th January 2014, 12:39
  3. scene->addItem() moans about QTimer ???
    By enno in forum Qt Programming
    Replies: 5
    Last Post: 17th December 2010, 15:02
  4. Segmentation Faul using addItem (QListWidget)
    By gnusar in forum Qt Programming
    Replies: 3
    Last Post: 8th November 2008, 10:27
  5. QListWidget::addItem and display immediately
    By vlg789 in forum Qt Programming
    Replies: 6
    Last Post: 24th September 2007, 16:30

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