Click here to Skip to main content
14,732,921 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hello everybody.
When I have been studying this book : "Qt GUI Programming with Qt4, Second Edition"; saw an example which I implemented it on my Ubuntu, but it NOT compiled ...
And the given error when I try to make it, is :
finddialog.cpp:26:40: error: no matching function for call to ‘QVBoxLayout::addWidget(QHBoxLayout*&)’
finddialog.cpp:26:40: note: candidate is:
/usr/include/qt4/QtGui/qboxlayout.h:85:10: note: void QBoxLayout::addWidget(QWidget*, int, Qt::Alignment)
/usr/include/qt4/QtGui/qboxlayout.h:85:10: note:   no known conversion for argument 1 from ‘QHBoxLayout*’ to ‘QWidget*’


Although I don't manipulation the codes!
I know the nature of the error, but I don't know how to solve it ...
The codes that have beed this error are :
QHBoxLayout *topLeftLayout = new QHBoxLayout;
    topLeftLayout->addWidget(label);
    topLeftLayout->addWidget(lineEdit);
    QVBoxLayout *leftLayout = new QVBoxLayout;
    leftLayout->addWidget(topLeftLayout); // this line have an error -> note: 
                                // no matching function for call to 
                                // ‘QVBoxLayout::addWidget(QHBoxLayout*&)’
                 // note: candidate is:
                 // /usr/include/qt4/QtGui/qboxlayout.h:85:10: note: 
                 // void QBoxLayout::addWidget(QWidget*, int, Qt::Alignment)


what is the problem? and how to solve it?
Thanks everybody.
---
finddialog.h -> http://ubuntuone.com/0burFhFtN2mJbJhowBM51b[^]
finddialog.cpp -> http://ubuntuone.com/2WhfmK2hLPb0HrQCH2EwXp[^]
main.cpp -> http://ubuntuone.com/5Q23kS6xHcNUlB3Z0zYsgn[^]
terminal output -> http://ubuntuone.com/6ve3wygjYu31rYWlLgO8KJ[^]
Posted

1 solution

Try this:

    QHBoxLayout *topLeftLayout = new QHBoxLayout;
    QVBoxLayout *leftLayout = new QVBoxLayout;
    topLeftLayout->addWidget(label);
    topLeftLayout->addWidget(lineEdit);

    //leftLayout->addWidget(topLeftLayout);
    leftLayout-> addLayout(topLeftLayout);
</pre>
   
v2
Comments
smss IR 5-Jul-13 9:41am
   
Thanks a lot du[DE].

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900