LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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

Reply
 
LinkBack Search this Thread
Old 11-05-2009, 03:26 AM   #1
threaderslash
Member
 
Registered: Dec 2008
Location: HongKong
Distribution: Fedora/Centos/RedHat
Posts: 109

Rep: Reputation: 15
Cool Clean Qt selection comboBox


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.
 
Old 11-05-2009, 05:00 PM   #2
threaderslash
Member
 
Registered: Dec 2008
Location: HongKong
Distribution: Fedora/Centos/RedHat
Posts: 109

Original Poster
Rep: Reputation: 15
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 05:12 PM.
 
  


Reply

Tags
member


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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


All times are GMT -5. The time now is 01:17 PM.

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
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration