Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8679673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:02:05+00:00 2026-06-12T21:02:05+00:00

I can’t get QComboBox::findData to work properly in my PyQt application. It seems as

  • 0

I can’t get QComboBox::findData to work properly in my PyQt application.

It seems as if PyQt doesn’t compare QVariant’s with Python tuples properly, causing Qt not to find my tuples. Example follows:

import sip
sip.setapi('QVariant', 2)
from PyQt4 import Qt

a = Qt.QApplication([])

cb = Qt.QComboBox()
cb.addItem("Bah", (1,2))
cb.addItem("Foo", (3,4))

print cb.findData((1,2))
print cb.findData((3,4))

print cb.itemData(0)
print cb.itemData(1)

print cb.findData(cb.itemData(0))
print cb.findData(cb.itemData(1))

With api=2 (auto-convert QVariant<->python) it does not find anything and I get the following output:

-1
-1
(1, 2)
(3, 4)
-1
-1

With api=1 (no auto-convert), it only finds it in the latter (useless) case:

-1
-1
<PyQt4.QtCore.QVariant object at 0x02FBF148>
<PyQt4.QtCore.QVariant object at 0x02FBF148>
0
1

Any idea how to get the first case working (findData with new tuples, and auto-convert QVariant) ?

(Using PyQt 4.8.3, SIP 4.12.1 and Qt 4.6.1)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T21:02:06+00:00Added an answer on June 12, 2026 at 9:02 pm

    From @ekhumoru’s comment above, replacing the tuples with lists is a suitable workaround: (my epmhasis)

    This is probably more of a limitation rather than a bug. Behind the
    scenes, PyQt has to attempt conversion of Python types for certain
    operations. Obviously, not all combinations of type/operation are
    supported. Mutability seems to be one limiting factor. If the tuples
    are exchanged for lists, the above example code will work.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain why this doesn't work? MyClass myClass1 = new MyClass(); object
Can anyone help me trying to find out why this doesn't work. The brushes
Can I change the field public virtual ClassOne ClassOne { get; set; } to
Can any one tell, how to get the result of LINQ query contains group
Can I be sure about the order in a Python dictionary? The function op.GetTangent(id)
Can somebody help me convert this VB function to Perl (PHP, Ruby or Python
Can i get the source code for a WAMP stack installer somewhere? Any help
Can find why i get this error can someone help? package Android.data; public class
Can anyone let me know how can we change the value of kendo combobox
Can I order my users in the database, so I don't have to say

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.