ber0y
16th July 2009, 10:14
Hi,
I think that the problem is easy, but i don't know how to process for this:
I just want to reimplement QComboBox::showPopup() in my new class that inherit from QComboBox, but I want to reuse the given code and just add one line.
I can't because:
`QComboBoxPrivate* QComboBox::d_func()' is private
mycombobox.cpp:24: error: within this context
mycombobox.cpp:31: error: invalid use of undefined type `struct QAbstractItemView'
d:/Outils/Qt/qt/qt/include/QtGui/../../src/gui/itemviews/qabstractitemdelegate.h:59: error: forward declaration of `struct QAbstractItemView'
mycombobox.cpp:31: error: invalid use of undefined type `struct QComboBoxPrivate'
d:/Outils/Qt/qt/qt/include/QtGui/../../src/gui/widgets/qcombobox.h:60: error: forward declaration of `struct QComboBoxPrivate'
mycombobox.cpp:32: error: `QItemSelectionModel' has not been declared
mycombobox.cpp:32: error: `ClearAndSelect' was not declared in this scope
mycombobox.cpp:33: error: invalid use of undefined type `struct QComboBoxPrivate'
...
My code:
#include <QComboBox>
class MyComboBox : public QComboBox
{
public:
MyComboBox (QWidget *parent);
virtual void showPopup();
};
/*!
Displays the list of items in the combobox. If the list is empty
then the no items will be shown.
If you reimplement this function to show a custom pop-up, make
sure you call hidePopup() to reset the internal state.
*/
void MyComboBox::showPopup()
{
// i just try this part of the code
Q_D(QComboBox);
if (count() <= 0)
return;
QStyle * const style = this->style();
view()->selectionModel()->setCurrentIndex(d->currentIndex,
QItemSelectionModel::ClearAndSelect);
QComboBoxPrivateContainer* container = d->viewContainer();
/* ... */
How could i reuse the code for this method please ? :confused:
Thanks.
I think that the problem is easy, but i don't know how to process for this:
I just want to reimplement QComboBox::showPopup() in my new class that inherit from QComboBox, but I want to reuse the given code and just add one line.
I can't because:
`QComboBoxPrivate* QComboBox::d_func()' is private
mycombobox.cpp:24: error: within this context
mycombobox.cpp:31: error: invalid use of undefined type `struct QAbstractItemView'
d:/Outils/Qt/qt/qt/include/QtGui/../../src/gui/itemviews/qabstractitemdelegate.h:59: error: forward declaration of `struct QAbstractItemView'
mycombobox.cpp:31: error: invalid use of undefined type `struct QComboBoxPrivate'
d:/Outils/Qt/qt/qt/include/QtGui/../../src/gui/widgets/qcombobox.h:60: error: forward declaration of `struct QComboBoxPrivate'
mycombobox.cpp:32: error: `QItemSelectionModel' has not been declared
mycombobox.cpp:32: error: `ClearAndSelect' was not declared in this scope
mycombobox.cpp:33: error: invalid use of undefined type `struct QComboBoxPrivate'
...
My code:
#include <QComboBox>
class MyComboBox : public QComboBox
{
public:
MyComboBox (QWidget *parent);
virtual void showPopup();
};
/*!
Displays the list of items in the combobox. If the list is empty
then the no items will be shown.
If you reimplement this function to show a custom pop-up, make
sure you call hidePopup() to reset the internal state.
*/
void MyComboBox::showPopup()
{
// i just try this part of the code
Q_D(QComboBox);
if (count() <= 0)
return;
QStyle * const style = this->style();
view()->selectionModel()->setCurrentIndex(d->currentIndex,
QItemSelectionModel::ClearAndSelect);
QComboBoxPrivateContainer* container = d->viewContainer();
/* ... */
How could i reuse the code for this method please ? :confused:
Thanks.