Reply
Thread Tools
Posts: 289 | Thanked: 101 times | Joined on Oct 2009
#11
Originally Posted by Diph View Post
That shouldn't be a problem.

But if you have it like this way there is a problem:

file1.h:
Code:
#include "file2.h"
file2.h
Code:
#include "file1.h"
Use forward declaration like rooster13 said.
Thats not the way I am doing it.
There is so much useless code as I am not really doing anything so I will try to explain it instead.

http://yfrog.com/j3delegatep
This is the way I want it to be. Right now there is just a listdelegate on listwindow. If I make an #include on programinfo or dayview I get the problem telling me it have already been declared.

In the listwindow.h I have #include "listdelegate.h" and in the listwindow.cpp it looks like this
Code:
lstExercises = new QListView();
    lstExercises->setModel(model);
    lstExercises->setItemDelegate(new ListDelegate(lstExercises));

Last edited by Lullen; 2010-11-15 at 21:13.
 
rooster13's Avatar
Posts: 319 | Thanked: 221 times | Joined on Jan 2010 @ Finland
#12
What is the exact error message u r getting?
 
Posts: 289 | Thanked: 101 times | Joined on Oct 2009
#13
In file included from ..\Meexercise\/listwindow.h:8,

from ..\Meexercise\/groupwindow.h:5,

from ..\Meexercise\/mainwindow.h:6,

from ..\Meexercise\main.cpp:2:

..\Meexercise\/listdelegate.h:10: error: redefinition of 'class ListDelegate'

..\Meexercise\/listdelegate.h:11: error: previous definition of 'class ListDelegate'

Line 10 &11 in listdelegate.h is:
class ListDelegate : public QAbstractItemDelegate
{

thank you for your help!
 
rooster13's Avatar
Posts: 319 | Thanked: 221 times | Joined on Jan 2010 @ Finland
#14
I think this will solve your problem.
 

The Following User Says Thank You to rooster13 For This Useful Post:
Posts: 289 | Thanked: 101 times | Joined on Oct 2009
#15
Yes thank you! Strange tho that you did not have the problem. The problem was that the #endif was not at the end of the listdelegate.h. Anyway thank you for the code!
 
rooster13's Avatar
Posts: 319 | Thanked: 221 times | Joined on Jan 2010 @ Finland
#16
I only use the delegate in one class.
All the QListWidgets come from the same dialog so that's why I did not have the problem I suppose.

But good that we got your problem solved.
 
Reply

Thread Tools

 
Forum Jump


All times are GMT. The time now is 18:10.