Click here to Skip to main content
15,892,298 members

Qt make error about matching functions

smss IR asked:

Open original thread
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 :
C++
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[^]
Tags: QT, Layout

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



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