Results 1 to 8 of 8

Thread: Debugging help

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Aug 2010
    Posts
    107
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Debugging help

    That was a stupid mistake....yes it was! But the combobox is still set to the first item. This doesn't seem to be working:
    Qt Code:
    1. nameIndex=ui->cmbName->currentIndex();//should get the current index to load later but for some reason always gets set to 0
    2. updateNameComboBox();
    3. ui->cmbName->setCurrentIndex(nameIndex);//the combobox returns to the first item
    To copy to clipboard, switch view to plain text mode 
    name index is always 0.

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

    Default Re: Debugging help

    An index looses its meaning after updating a list.

    You should get the index again after updating. You can use the string for example to find the index (difficult if you allow multiple items with the same string). Or use the userdata.

  3. The following user says thank you to tbscope for this useful post:

    nirab_25 (6th November 2010)

  4. #3
    Join Date
    Aug 2010
    Posts
    107
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Debugging help

    I guess I might have been going about this in the wrong way, but I am not sure what would be the correct way. I have an address book database with first name, last name, address, etc in the table. Then I have a dialog widget with a combo box and some lineedit widgets. The combobox gets populated with the first and last name combined. The lineedit widgets are used for input/corrections. If the user corrects the name, I want the database updated and the combobox updated as well and then the combobox set to the person that was being edited. What I did was to have a static variable- nameIndex to hold the index of the combobox that is being edited and when the combobox gets repopulated (it should have the same data with the corrections) set the currentIndex to the previously stored number. Why doesn't this work or what would be a better way? Get the ID and use a loop to go through all the items until there is a match with ID?
    Also, what is the difference with QDebug and qDebug? Why does one work and the other not? Which one is better? and how do I use QDebug?

  5. #4
    Join Date
    Aug 2010
    Posts
    107
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Debugging help

    I know that static variables are not recommended and at the time, I didn't see how to avoid it....and the result was the error I was experiencing (in addition to trying to maintain the index of the combobax when I didn't need to) I got it fixed. but the question still remains:
    QDebug vs qDebug....what is the difference which is better?

    Thanks

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

    Default Re: Debugging help

    It is explained here:
    http://doc.qt.nokia.com/4.7/qdebug.html

    qDebug() is a convenience function returning a QDebug object making use of the default message handler.

  7. #6
    Join Date
    Aug 2010
    Posts
    107
    Qt products
    Qt4
    Platforms
    Windows
    Thanks
    5

    Default Re: Debugging help

    Thanks.....I will get this figured out eventually!!!

Similar Threads

  1. Replies: 3
    Last Post: 7th September 2010, 00:00
  2. SXE key has not been set when debugging
    By learning_qt in forum Qt for Embedded and Mobile
    Replies: 0
    Last Post: 24th September 2008, 09:59
  3. Debugging Qt
    By baray98 in forum Qt Programming
    Replies: 0
    Last Post: 7th May 2008, 01:16
  4. Debugging with gdb
    By SteM in forum Newbie
    Replies: 4
    Last Post: 9th August 2007, 15:40
  5. Debugging
    By Voldemort in forum Qt Programming
    Replies: 13
    Last Post: 14th May 2007, 21: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
  •  
Qt is a trademark of The Qt Company.