use currentRow thenOriginally Posted by ankurjain
![]()
use currentRow thenOriginally Posted by ankurjain
![]()
a life without programming is like an empty bottle![]()
hi all,
hav a look at my code
this i did to get the combo in first row with all the unique values in the columns below each of them.Qt Code:
void QGrid::autoFilter() { int columnCount = this->columnCount(); int rowCount = this->rowCount(); QStringList filter; QString temp_string; QComboBox *newCombo; for(int c = 0;c<columnCount;c++) { for(int r = 1; r<rowCount;r++) { temp_string = this->item(r,c)->text(); if(!filter.contains(temp_string)) filter << temp_string; } filter << "None"; newCombo->addItems(filter); newCombo->setCurrentIndex(filter.count()-1); this->setCellWidget(0,c,newCombo); filter.clear(); } }To copy to clipboard, switch view to plain text mode
now look at the image below :
what i did, selected the lower cell first, then selected the combo, then also the focus from the lower cell isn't going. here two cells are selected simultaneously.
if i try to get the cell contents for the first row(having combo) using this->item(0,0), it ain't giving the text of the combo...
pls suggest something ...
Last edited by ankurjain; 19th May 2006 at 10:10.
Do what u r afraid to do, and the death of fear is sure.
If the combo box is placed as a cell widget, the current column and current row is not updated "correctly" when interacting with the combo. This is because the combo box is over the cell and therefore the cell doesn't get selected.
- store combos as member variables, maybe event map them somehow to their cells (QMap<QPoint, QComboBox*> for instance)
- subclass qcombobox and add properties for row and column
- use qobject's objectname property to store a qpoint
J-P Nurmi
ankurjain (19th May 2006)
Qt Code:
// set column index for combo boxes // the slot void testAnother(const QString& text) { // retrieve column index of the sender of the signal int c = sender()->objectName().toInt(); }To copy to clipboard, switch view to plain text mode
J-P Nurmi
ankurjain (19th May 2006)
jpn:
thanx buddy.... i worked the 3rd solution.
thanx to munna, zlatko and all others who read the post and replied ....
this forum is really helpful to me ....
Do what u r afraid to do, and the death of fear is sure.
I also want to do the same thing and I have approached to implement this thing is, I subclass the QComboBox and add some my custom slot and signal.
header file
Qt Code:
#ifndef _MY_COMBO_BOX_H #define _MY_COMBO_BOX_H #include <qobject.h> #include <qcombobox.h> //***********Defination of OdyComboBox**************** { Q_OBJECT public: signals: public slots: private: int row; int column; }; #endifTo copy to clipboard, switch view to plain text mode
and source File
Qt Code:
//***********Implementation of OdyComboBox**************** setPaletteBackgroundColor( Qt::white ); } emit activated( row, column, string ); }To copy to clipboard, switch view to plain text mode
ankurjain (23rd May 2006)
hi sumsin,
ur implementation was nice .... i got a bit confused in the code :
Qt Code:
To copy to clipboard, switch view to plain text mode
u inherited QComboBox, now in the constructor, what the lines row(row),column(column) mean?
Qt Code:
emit activated( row, column, string ); }To copy to clipboard, switch view to plain text mode
here how u got the row and column ?
i am a new user to this ..... so if its too easy, then also pls reply ....
Do what u r afraid to do, and the death of fear is sure.
This is NOT inside QComboBox's constructor. Row and Column are getting initialized.u inherited QComboBox, now in the constructor, what the lines row(row),column(column) mean?
row and column are member variables of CMyComboBox.here how u got the row and column ?
Mithin
www.mithin.in
ankurjain (23rd May 2006)
Exactly. What munna says.
Thanks munna.![]()
Dear Ankur,
Could you please provide the complete code .I am beginner and not able to do anything after implementation of combo box.
Thanks in advance.
Added after 1 39 minutes:
Dear Jpn,
could you please help me how to implement " qobject's objectname property to store a qpoint" feature.I have implemented on same way as ankur has mentioned and now i am getting combo box on my table but not getting any idea to implement slot named testAnother. As i m beginner and i don't have any more idea about this.So request you to please help me out from this problem.
Thanks in advance
Last edited by lekhrajdeshmukh; 6th December 2011 at 11:03.
Bookmarks