LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-28-2010, 04:38 AM   #1
Squall90
Member
 
Registered: Oct 2009
Distribution: Currently several distros :S
Posts: 148

Rep: Reputation: 29
QWebView, forward declaration, "error: forward declaration of 'struct QWebView'"


Hi there,

I am trying to include a QWebView widget in my application. Every time I try to compile it, I just get these errors:
Code:
$ LANG=en_US make
g++ -c -pipe -O2 -march=i486 -mtune=i686 -Wall -W -D_REENTRANT -DQT_NO_DEBUG -DQT_WEBKIT_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -DQT_SHARED -I/usr/lib/qt/mkspecs/linux-g++ -I. -I/usr/lib/qt/include/QtCore -I/usr/lib/qt/include/QtNetwork -I/usr/lib/qt/include/QtGui -I/usr/lib/qt/include/QtWebKit -I/usr/lib/qt/include -I. -I. -o main.o main.cpp
main.cpp: In constructor 'WebView::WebView()':
main.cpp:14: error: invalid use of incomplete type 'struct QWebView'
main.cpp:3: error: forward declaration of 'struct QWebView'
main.cpp:15: error: invalid use of incomplete type 'struct QWebView'
main.cpp:3: error: forward declaration of 'struct QWebView'
main.cpp: In function 'int main(int, char**)':
main.cpp:23: error: invalid use of incomplete type 'struct QWebView'
main.cpp:3: error: forward declaration of 'struct QWebView'
main.cpp:24: error: 'class WebView' has no member named 'exec'
make: *** [main.o] Error 1

qwebview.pro
Code:
TEMPLATE = app
TARGET = 
DEPENDPATH += .
INCLUDEPATH += .

QT += gui core webkit network

# Input
SOURCES += main.cpp

main.cpp
Code:
#include <QtGui>

class QWebView;

class WebView : public QMainWindow
{
	Q_OBJECT

public:
	QWebView *view;

	WebView() 
	{
		view = new QWebView(this);
		view->load(QUrl("http://www.google.com"));
	}
};

int main(int argc, char **argv)
{
	QApplication app(argc, argv);
	WebView *view = new WebView;
	view->view->show();
	return view->exec();
}
I know, it has something to do that I forward declare the QWebView class but all examples are written this way, so way shouldn't I do it this way?
http://doc.qt.nokia.com/4.6/webkit-fancybrowser.html

How to solve this problem?


Thanks
 
Old 12-28-2010, 05:40 AM   #2
Squall90
Member
 
Registered: Oct 2009
Distribution: Currently several distros :S
Posts: 148

Original Poster
Rep: Reputation: 29
_________________________

I got the solution myself... Every time I have problems that seem to be unsolveable I post on web forums and a short time after posting, I find the solution myself... This sucks~

However, I saw a difference in the Nokia/Qt example. It only forward declare the QWebView class in the header file and it includes QWebKit in the main.cpp file.
Another problem (only in my test program is, that I cannot make the class "Q_OBJECT" without and additional header file.


Thanks anyway.


damn... I clicked on the edit button but entered the text in the "Quick Reply box". Sorry ...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gcc C language forward declaration problem yousafsajjad Programming 7 07-22-2010 04:09 PM
invalid use of incomplete type (co-dependant classes and forward declaration) quantum_leaf Programming 4 02-12-2010 07:42 AM
C declaration problem for a "typedef struct". Spirals Linux - Software 3 03-17-2008 07:52 AM
Not accepting the forward declaration. manikan Programming 3 02-10-2006 02:46 AM
cpp forward declaration error ashirazi Programming 5 09-17-2004 12:55 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:11 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration