Results 1 to 3 of 3

Thread: Why "setCurrentItem" in a QComboBox doesn't change the text shown?

  1. #1
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Smile Why "setCurrentItem" in a QComboBox doesn't change the text shown?

    Hi all, I need to use a QComboBox to let the user introduce the path to a directory. I have a button connected to a slot where I call to QFileDIalog::getExistingDirectory. So the user can choose a directory in the file system. When this dialog is closed I check if the path exists in the combo box with QComboBox::findText. If it's not present I call to QComboBox::addITem to add this new path. If it's present I call to QComboBox::setCurrentIndex with the index obtained from "findText". The problem is that it doesn't change the text that is shown in the combo box. Is it the correct behaviour or I am doing something wrong?

    Thanks.

  2. #2
    Join Date
    Jan 2006
    Posts
    667
    Thanks
    10
    Thanked 80 Times in 74 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Why "setCurrentItem" in a QComboBox doesn't change the text shown?

    Check if your findText(QString &) is returning the correct index or is it returning -1.

  3. #3
    Join Date
    Jan 2006
    Posts
    105
    Thanks
    38
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: Why "setCurrentItem" in a QComboBox doesn't change the text shown?

    Quote Originally Posted by munna
    Check if your findText(QString &) is returning the correct index or is it returning -1.
    That was exactly the problem I had to convert the separator of the path with QDir::convertSeparators before check if it exists in the combo Thanks

Similar Threads

  1. Unhandled exception in qatomic
    By NewGuy in forum Qt Programming
    Replies: 14
    Last Post: 23rd July 2013, 09:49
  2. Replies: 1
    Last Post: 15th January 2009, 10:34
  3. Replies: 8
    Last Post: 15th May 2007, 09:21
  4. Can't change the text display of a QTreeview item.
    By johnny_sparx in forum Qt Programming
    Replies: 3
    Last Post: 2nd June 2006, 01:03
  5. Change the text color tab page
    By gtthang in forum Qt Programming
    Replies: 4
    Last Post: 18th February 2006, 17:38

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.