PDA

View Full Version : QComboBox Custom Widget has missing designer properties



vieraci
6th December 2009, 11:08
I can't understand why my custom widget is missing some designer functions, like in designer,
the custom widget doesn't have any tab order and it doesn't appear in the tab order list.

I'm thinking it's because I've placed it in a layout which doesn't have a tab order ?
I had to do this because without it, my widget didn't show up when placing it on a form.


DbComboBox::DbComboBox(QWidget *parent)
: QWidget(parent)
{
cb = new QComboBox(this);
cb->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
cb->setEditable(true);
cb->installEventFilter(this);
connect(cb, SIGNAL(currentIndexChanged(int)), this, SLOT(on_currentIndexChanged(int)));
QHBoxLayout *layout = new QHBoxLayout;
layout->addWidget(cb);
layout->setContentsMargins(0,0,0,0);
this->setLayout(layout);
}


Also QComboBox public methods aren't available, when I compile my project with an instance of this part and access a method:

m_ui->myComboBox->currentText
compiler says

/home/vince/projects/Qt/myProject/plugins/DbComboBoxExtension/dbcombobox.h:56: error: ‘QString DbComboBox::currentText’ is private

Can someone please point out why it isn't behaving ?

aamer4yu
7th December 2009, 04:42
Search for currentText in your class declaration.
May be you hav declared it private, or there some member variable by that name

vieraci
7th December 2009, 05:55
Search for currentText in your class declaration.
May be you hav declared it private, or there some member variable by that name

currentText is a public method of QComboBox, but it's now private.
Why ? I don't think I should have to expose every method ?

aamer4yu
7th December 2009, 09:38
I dont mean u will have to expose methods...what I mean is check if by mistake you have declared it as private...

vieraci
7th December 2009, 10:12
I dont mean u will have to expose methods...what I mean is check if by mistake you have declared it as private...

WOW! I Can't believe I DID declare a private variable by that name :o
Now I remember why I did that too. Thanks for pointing it out.
Now I'm left with my original problem...custom widget's tab order feature isn't there in designer.
I'm positive it's something to do with it being a child of the layout. So how do I get rid of the layout ? have to re-implement paint event maybe ? how ?

vieraci
9th December 2009, 13:30
I still haven't worked it out, if this is a sticky one at least if I can get a reply stating "don't know" I'd feel better.