How to change Qcombobox popup width
-
[quote author="raven-worx" date="1375899990"]this->view() returns an QAbstractItemView which is derived from QWidget. QWidget has a method named setMinimumWidth() ....
what Qt version do you use?![/quote]Sure, QWidget has a member function setMinimumWidth(),
my problem is inside setMinimumWidth(),
this->view()->sizeHintForColumn(0) ( QWidget hasn't a methode sizeHintForColumn(0)
-
no...but QAbstractItemView does!
Since you implicitly cast the view instance to a QWidget it's clear that the compiler complains about it! -
change the line
@
QWidget *view = this->view() ;
@
to
@
QAbstractItemView *view = this->view() ;
@or just use the code i've posted in first place!
-
[quote author="raven-worx" date="1375946208"]change the line
@
QWidget *view = this->view() ;
@
to
@
QAbstractItemView *view = this->view() ;
@or just use the code i've posted in first place![/quote]
also not working for me , always the width of Qtableview don't increased
-
like so,
////////////////////////////////
// combobox //
//////////////////////////////////////////////////////////////////////////////////
// Qtableview her with all cells inside it ** Horizontal Header //
/////////////////////////////////////////////////////////////////////////////////
/// row 0 //
/////////////////////////////////////////////////////////////////////////////////
/// row 1 //
/////////////////////////////////////////////////////////////////////////////////
/// row 2 //
///////////////////////////////////////////////////////////////////////////////// -
This works perfect, Thank you very much.
[quote author="raven-worx" date="1375879559"]you can subclass QComboBox and reimplement showPopup() method if you need the size content dependent. Something like this:
@
void MyComboBox::showPopup()
{
this->view()->setMinimumWidth(this->view()->sizeHintForColumn(0));
QComboBox::showPopup();
}
@[/quote]