LinuxQuestions.org
Did you know LQ has a Linux Hardware Compatibility List?
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Tags used in this thread
Popular LQ Tags

Reply
 
Thread Tools
Old 11-05-2009, 04:26 AM   #1
threaderslash
Member
 
Registered: Dec 2008
Location: Australia
Distribution: Fedora/Centos/RedHat
Posts: 80
Thanked: 0
Cool Clean Qt selection comboBox


[Log in to get rid of this advertisement]
Hi Everybody..

I am using Qt and need to build a selection comboBox -- e.g.:
http://www.java2s.com/Tutorial/VBIma...ntAddValue.PNG .

The problem is - after one choice was made, and the code run, for the next time the user select a different choice, both, the present and all past choices run. See what I mean:

Code:
selected color - blue
we are on runBlue
selected color - red
we are on runBlue
we are on runRed
Here is the code:
Code:
.........................................
QtCore.QObject.connect(self.selectComboBox, 
			QtCore.SIGNAL("currentIndexChanged(QString)"), 
			self.combo_activateInput)   
.........................................
def combo_activateInput(self):
        color=unicode(self.selectComboBox.currentText())
        if(color == "blue"):
            print "selected color - blue"
            QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), self.combo_runBlue)
        if(color == "red"):
            print "selected color - red"
            QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), self.combo_runRed)               
        if(color == "yellow"):
            print "selected color - yellow"
            QtCore.QObject.connect(self.okButton, QtCore.SIGNAL("clicked()"), self.combo_runYellow)
        del color 
.........................................
def combo_runBlue(self):
        print "we are on runBlue"

def combo_runRed(self):
        print "we are on runRed"

def combo_runYellow(self):
        print "we are on runYellow"
I run "del color" to clean the content returned by selectComboBox.currentText, but it didn't clean the content indeed.

So, any suggestion? All comments and suggestions are highly appreciated.
windows_xp_2003 threaderslash is offline  
Tag This Post
Reply With Quote
Old 11-05-2009, 06:00 PM   #2
threaderslash
Member
 
Registered: Dec 2008
Location: Australia
Distribution: Fedora/Centos/RedHat
Posts: 80
Thanked: 0

Original Poster
Lightbulb solved

Here is the solution:
Code:
    def combo_runBlue(self):
        print "we are on runBlue"
        QtCore.QObject.disconnect(self.okButton, QtCore.SIGNAL("clicked()"), self.combo_runBlue)
Hope this can help others too.

Last edited by threaderslash; 11-05-2009 at 06:12 PM..
windows_xp_2003 threaderslash is offline  
Tag This Post
Reply With Quote



Reply

Bookmarks


Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Domain combobox doesn't appear on KDE login screen Maaras Suse/Novell 0 03-20-2009 12:44 AM
Javascript:Combobox creation taking data from DB On button click Manashi Programming 4 03-31-2006 04:02 AM
gtkmm combobox problem shmonkey Programming 2 03-26-2005 06:07 PM
How to open a Combobox in GTK captainfreedom Programming 0 05-30-2004 04:26 AM
clean install, but three selection in the grub wood Linux - General 4 10-25-2003 03:04 PM


All times are GMT -5. The time now is 12:15 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration