Results 1 to 4 of 4

Thread: access selected value of QcomboBox has problem

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Feb 2016
    Posts
    16
    Qt products
    Qt5 Qt/Embedded
    Platforms
    Unix/X11

    Question access selected value of QcomboBox has problem

    I set a QcomboBox in gui widget and ,I add item

    Qt Code:
    1. for(int i = 1; i < 31; i++)
    2. {
    3. ui->combo->addItem(QString::number(i));
    4. }
    To copy to clipboard, switch view to plain text mode 
    and in QComboBox slot I want to get selected value by

    Qt Code:
    1. int index =ui->combo->itemData( ui->combo->currentText());
    To copy to clipboard, switch view to plain text mode 
    but have error :316: error: no matching function for call to 'QComboBox::itemData(QString)'

    if I use currentIndex instead of currentText return 0 when print it; addItem get Qstring ,

    Qt Code:
    1. void QComboBox::addItem(const QString & text, const QVariant & userData = QVariant())
    To copy to clipboard, switch view to plain text mode 
    and ItemData work with currentIndex,

    I use insertItem and it has sae error ,so how can set value or text and get slected value??
    Last edited by isan; 26th April 2016 at 07:38.

Similar Threads

  1. Replies: 5
    Last Post: 17th February 2015, 23:21
  2. Replies: 0
    Last Post: 31st October 2011, 14:11
  3. Replies: 0
    Last Post: 1st September 2011, 15:20
  4. Replies: 2
    Last Post: 28th April 2011, 14:43
  5. QComboBox: how to get selected value?
    By Ivan Khromov in forum Newbie
    Replies: 4
    Last Post: 2nd April 2011, 13:05

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.