Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: QT Layout
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 4-Jul-13 17:07pm
smss IR399

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

Try this:
 
    QHBoxLayout *topLeftLayout = new QHBoxLayout;
    QVBoxLayout *leftLayout = new QVBoxLayout;
    topLeftLayout->addWidget(label);
    topLeftLayout->addWidget(lineEdit);
 
    //leftLayout->addWidget(topLeftLayout);
    leftLayout-> addLayout(topLeftLayout);
</pre>
  Permalink  
v2
Comments
smss IR at 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)

  Print Answers RSS
0 OriginalGriff 6,569
1 Sergey Alexandrovich Kryukov 6,168
2 DamithSL 5,228
3 Manas Bhardwaj 4,717
4 Maciej Los 4,150


Advertise | Privacy | Mobile
Web03 | 2.8.1411022.1 | Last Updated 5 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100