By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,327 Members | 1,759 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,327 IT Pros & Developers. It's quick & easy.

boost.bind problems

P: n/a
Hi,

at this time I try to combine Qt and boost. Unfortunately I've run into
trouble:

void QWidget::insertAction ( QAction * before, QAction * action );
class QAction : public QWidget { ... };

class ActionCategory {
...
QList<QAction*m_actionList;
};

....
std::for_each(m_actionList.begin(), m_actionList.end(),
boost::bind(&QWidget::insertAction, _1, 0, _2));

which shall replace:

foreach(QAction* action, m_actionList)
insertAction(0, action);
What's wrong?

Thanks
Olaf

The error is:
Gui/ActionCategory.cpp: In member function »QMenu*
eda::ActionCategory::updateMenu(QMenu*)«:
Gui/ActionCategory.cpp:240: Fehler: expected `)' before numeric constant
/usr/include/boost/bind.hpp: At global scope:
/usr/include/boost/bind.hpp: In instantiation of
»boost::_bi::result_traits<boost::_bi::unspecified , void
(QWidget::*)(QAction*, QAction*)>«:
/usr/include/boost/bind/bind_template.hpp:15: instantiated from
»boost::_bi::bind_t<boost::_bi::unspecified, void (QWidget::*)(QAction*,
QAction*), boost::_bi::list2<boost::arg<1>, boost::arg<2 >«
Gui/ActionCategory.cpp:240: instantiated from here
/usr/include/boost/bind.hpp:64: Fehler: »void (QWidget::*)(QAction*,
QAction*)« ist kein Klassen-, Struktur- oder Union-Typ
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:
In function »_Function std::for_each(_InputIterator, _InputIterator,
_Function) [with _InputIterator = QList<QAction*>::iterator, _Function =
boost::_bi::bind_t<boost::_bi::unspecified, void (QWidget::*)(QAction*,
QAction*), boost::_bi::list2<boost::arg<1>, boost::arg<2 >]«:
Gui/ActionCategory.cpp:240: instantiated from here
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/bits/stl_algo.h:159:
Fehler: keine Übereinstimmung für Aufruf von
»(boost::_bi::bind_t<boost::_bi::unspecified, void
(QWidget::*)(QAction*, QAction*), boost::_bi::list2<boost::arg<1>,
boost::arg<2 >) (QAction*&)«
Feb 21 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On 21 Feb, 19:55, Olaf Petzold <o...@mdcc.dewrote:
Hi,

at this time I try to combine Qt and boost. Unfortunately I've run into
trouble:

void QWidget::insertAction ( QAction * before, QAction * action );
class QAction : public QWidget { ... };

class ActionCategory {
...
QList<QAction*m_actionList;

};

...
std::for_each(m_actionList.begin(), m_actionList.end(),
boost::bind(&QWidget::insertAction, _1, 0, _2));
for_each takes a unary function.
boost::bind(&QWidget::insertAction, _1, 0, _2)
creates a binary function and for_each will only
bind _1, _2 is left unbound
which shall replace:

foreach(QAction* action, m_actionList)
insertAction(0, action);
I suppose you want something like
std::for_each(m_actionList.begin(), m_actionList.end(),
boost::bind(&QWidget::insertAction, _1, 0, action) );
instead
Feb 22 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.