KDevelop tutorials

Code junkies hangout here

Moderators: ChrisThornett, LXF moderators

KDevelop tutorials

Postby pikkewyn » Fri Jul 08, 2005 6:42 am

I have just started following the KDE development tuorials from 2004. Everything has gone well and I have managed to work through most problems I have encountered. However this one has me stumped. Tutorial 5 from LXF58 (Oct 2004) contains the code ( in selectionbarcode.cpp )

#include "selectionbarcode.h"
#include <qmessagebox.h>
#include <qdir.h>
#include <qimage.h>
#include <qpixmap.h>


SelectionBarCode::SelectionBarCode(QWidget *parent, const char *name)
: SelectionBar(parent, name)
{
QDir dir("/sources/lxfgallery/testalbum");
if (!dir.exists())
{
qWarning("Cannot find the example directory");
}
else
{
const QFileInfoList *list = dir.entryInfoList("*.jpg *.png *.jpeg *.bmp *.tiff *.gif *.xpm");
QFileInfoListIterator iter( *list );
QFileInfo *fileinc;
while ( (fileinc = iter.current()) !=0)
{
QImage img(fileinc->absFilePath().latin1());
QPixmap pix(img.scale(64, 48, QImage::ScaleFree));

picList->insertItem(pix, fileinc->fileName().latin1());
++iter;
}


}


SelectionBarCode::~SelectionBarCode()
{
}

void SelectionBarCode::addAlbum()
{ QMessageBox::information( this,"LXFGallery","This Feature is not implemented yet.\n Because Your the developer couldn't be arsed!");
}


if I try and build this I get the following error

"/home/matthew/lxfgallery/src/selectionbarcode.cpp:45: error: `picList' undeclared (first use this function)
*** Exited with status: 2 ***"

Has anyone done the tutorials and had the same problem? if not where do I declare "picList"
pikkewyn
 
Posts: 3
Joined: Fri Jul 08, 2005 6:40 am

RE: KDevelop tutorials

Postby Nigel » Fri Jul 08, 2005 9:02 am

I've just skimmed through the articles, and it isn't obvious :(

However, I think the clue may lie on page 84 of LXF58, at the start of the "Beginning to code" paragraph.
It says "Before we go any further, ensure that you give the bottom list box widget a name in QT Designer". Taking that in conjunction with the comments on page 86, where the picList->Insert command is discussed, I would hazard a guess that you are supposed to have given the bottom list box widget the name "picList"...

Also note the Top Tip on page 97 of LXF59 about doing a Build->Distclean.
Hope this helps,

Nigel.
User avatar
Nigel
LXF regular
 
Posts: 1141
Joined: Fri Apr 08, 2005 8:03 pm
Location: Gloucestershire, UK

Postby pikkewyn » Fri Jul 08, 2005 5:05 pm

Thanks Nigel.
Will have a look at those points and let you know How I get on :)
pikkewyn
 
Posts: 3
Joined: Fri Jul 08, 2005 6:40 am

out of the frying pan

Postby pikkewyn » Sat Jul 09, 2005 11:16 am

Hi there.
in an earlier tutorial this lower KListBox was called thumbnailList not picList. however when I changed the name to picList I get the error
"/home/matthew/lxfgallery/src/selectionbarcode.cpp:45: error: invalid use of undefined type `struct KListBox'
./selectionbar.h:20: error: forward declaration of `struct KListBox'
which is referencing to selectionbar.h the file automatically created by Qt Designer

has anyone succeeded with this set of tutorials and have the code or do you think I should e-mail Jono Bacon
pikkewyn
 
Posts: 3
Joined: Fri Jul 08, 2005 6:40 am

RE: out of the frying pan

Postby Nigel » Sat Jul 09, 2005 5:48 pm

This could be where you need to do the Build->Distclean to make sure that all related files are recompiled/remade, especially selectionbar.h

Failing that, I think an email to Jono would be the fastest way to get you back on track.

Sorry, I haven't worked through these tutorials myself.
Hope this helps,

Nigel.
User avatar
Nigel
LXF regular
 
Posts: 1141
Joined: Fri Apr 08, 2005 8:03 pm
Location: Gloucestershire, UK

Postby kimdino » Sun Jul 24, 2005 7:43 pm

pikkewyns's problem is exactly the same as what brought me here. The difference is that I had tried using 'thumbnailList->insetItem' & have also tried DistClean. No joy with either :(

thumbnailList has no visible sign of an insertItem method though, being a listbox, there must be some way of adding items? The only functions I can find any mention of are those created in LXFGallery code.

My plan was then to compare his, presumably working, version with my typed-in-from-the-mag version to see where they differ. I was unable to find the code on the DVDs, but the mag gives the address as <www.jonobacon.org/minisites/linuxformat/kdevelopment> but this is a dead link. Does anyone know where I can pick up a copy of Jono's code?
kimdino
 
Posts: 2
Joined: Sun Jul 24, 2005 7:18 pm

LXFGallery

Postby holbromf » Fri Jul 29, 2005 6:49 am

Hi,
I am also going to complete Jono's tutorial even if it kills me.
I found that thumbnailList and picList are the same and I have used the latter.
Jono's site is under construction so we will have to wait to see the magic code.
I have a problem with the connect statement in LXF58. Did you guys manage to solve this? The message suggested the signature did not match anything in qlabel.h. I would appreciate some help here.

Cheers Mike
holbromf
 
Posts: 5
Joined: Fri Jul 29, 2005 6:42 am

Postby holbromf » Fri Jul 29, 2005 11:53 am

Hi,
I just solved the 'connect' problem.
I cast 'selectionBar' with (QObject*) i.e.

connect ( (QObject*)selectionBar->picList, SIGNAL( highlighted(QString&) ), etc, etc

Cheers Mike
holbromf
 
Posts: 5
Joined: Fri Jul 29, 2005 6:42 am

Postby holbromf » Sun Aug 07, 2005 11:55 am

Hi,
I have got through the eleven tutorials. I have a question about the resource file. I get the runtime message the system " cannot find .rc file lxfgalleryui.rc". Does anyone know which directory this file should go for the progran to find it automatically? I have tried src, debug/src and debug but to no availe. I would like to get the middle item in the file menu. Does this message mean the file was found but is incorrect in some way?


Cheers Mike
holbromf
 
Posts: 5
Joined: Fri Jul 29, 2005 6:42 am

Postby lcoopman » Mon Aug 29, 2005 6:28 pm

picList problem solved.
Open selectionbar.ui in Qt3 en change the name "thumbnailList" to "picList".
Another solution is the change the name "picList" to "thumbnailList" each time you need it in the code.
In selectionbarcode.h add the line #include <klistbox.h>.
lcoopman
 
Posts: 1
Joined: Fri Aug 26, 2005 6:41 pm

Postby Goran » Mon Aug 29, 2005 7:03 pm

I wanted to go through the tutorial, but I only have the parts starting from part 3. So I am waiting for the the first two parts to become avilable on the website so I can begin my journey. Are the old tutorials going to be uploaded any time soon ? I sure hope so :(
Goran
 
Posts: 5
Joined: Wed Aug 17, 2005 7:52 pm


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests