Results 1 to 3 of 3

Thread: QComboBox strange behavior

  1. #1
    Join Date
    Aug 2008
    Posts
    11
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default QComboBox strange behavior

    I'm using 4.4.3, so I'm trying to create a proof-of-concept page and playing with display widgets. I have a table with 2 columns (ID, Description) and want to store the ID in a Data Value field and Description in a Text Value field, and ID field invisible and Description field visible. I know how to do this in .Net C#, but how do I do this in Qt?

    This is what I've done:
    Qt Code:
    1. QComboBox *cmbBox = Concept::ui.cmbItems;
    2. _model->setQuery("select lookupid, lookupdescr from tblLookup");
    3. cmbBox->clear();
    4. cmbBox->setModel(_model);
    To copy to clipboard, switch view to plain text mode 


    But, only the ID field is shown, so I used:
    Qt Code:
    1. cmbBox->setModelColumn(1);
    To copy to clipboard, switch view to plain text mode 
    but either the primary key shows up, and the rest of the Description text, or only the first item and the second item is not visible.

    I've been searching for help, but the documentation doesn't tell me how to do this. I want to get the ID from the selected item, but not show it.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QComboBox strange behavior

    Quote Originally Posted by Antebios View Post
    but either the primary key shows up, and the rest of the Description text, or only the first item and the second item is not visible.
    What does this mean? The solution using setModelColumn() should have worked correctly - you should have gotten a combobox with values from the second column of your model.

  3. #3
    Join Date
    Aug 2008
    Posts
    11
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QComboBox strange behavior

    The latest Qt 4.5.0 solved this problem/bug.

Similar Threads

  1. strange QGraphicsView sizing behavior
    By tpf80 in forum Qt Programming
    Replies: 3
    Last Post: 1st February 2009, 20:04
  2. Very strange behavior of QWidget in Qt Designer
    By THRESHE in forum Qt Programming
    Replies: 10
    Last Post: 13th August 2008, 16:19
  3. Strange QTcpSocket behavior (debugged with Ethereal)
    By mdecandia in forum Qt Programming
    Replies: 23
    Last Post: 28th May 2007, 20:44
  4. Strange behavior with Drag and Drop (not always drops)
    By Mona Shokrof in forum Qt Programming
    Replies: 1
    Last Post: 27th May 2007, 18:00
  5. QComboBox +SUSE10.0 +qt4.1 strange behavior
    By antonio.r.tome in forum Qt Programming
    Replies: 6
    Last Post: 20th March 2006, 17:49

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.