LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 05-03-2009, 08:31 PM   #1
threaderslash
Member
 
Registered: Dec 2008
Location: HongKong
Distribution: Fedora/Centos/RedHat
Posts: 115

Rep: Reputation: 15
Cool Qt : ‘Qchar’ has not been declared


Hi Guys,

I am trying to run the example from the Qt4 2nd Edition - Blanchette.

Have done the page 38 example. But it doen't work.

Here is the message:

sortdialog.h:14: error: expected class-name before ‘{’ token
sortdialog.h:19: error: ‘Qchar’ has not been declared

I have then included in the files

#include <QString>
#include <QChar>

But the compile error keeps the same. I have used the QtDesigner then make changes to link the slots and events.

Has someone any hints, please??
 
Old 05-03-2009, 09:00 PM   #2
fantas
Member
 
Registered: Jun 2007
Location: Bavaria
Distribution: slackware, xubuntu
Posts: 143

Rep: Reputation: 22
QChar != Qchar
 
Old 05-03-2009, 09:21 PM   #3
threaderslash
Member
 
Registered: Dec 2008
Location: HongKong
Distribution: Fedora/Centos/RedHat
Posts: 115

Original Poster
Rep: Reputation: 15
Cool

Thanks! you're right.
Now just left one error:
sortdialog.h:14: error: expected class-name before ‘{’ token

here is part of the sortdialog.h:

//--------------------------------------//
class SortDialog : public QDialog, public Ui::SortDialog
{
Q_OBJECT;

public:
SortDialog(QWidget *parent=0);
void setColumnRange(QChar first, QChar last);
};
//--------------------------------------//

Maybe there some detail still missing. Some suggestion please?
 
Old 05-03-2009, 10:58 PM   #4
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
change the line of code on line 19 of "sortdialog.h" ( all Qchar's to char)
Quote:
sortdialog.h:19: error: ‘Qchar’ has not been declared
from "qchar " to " char "
 
Old 05-04-2009, 01:18 AM   #5
threaderslash
Member
 
Registered: Dec 2008
Location: HongKong
Distribution: Fedora/Centos/RedHat
Posts: 115

Original Poster
Rep: Reputation: 15
Cool

thanks a lot it worked now!
 
Old 05-05-2009, 05:17 PM   #6
sharky
Member
 
Registered: Oct 2002
Posts: 569

Rep: Reputation: 84
I'm getting a similar error with the exact same example from the book.

Quote:
In file included from main.cpp:2:
sortdialog.h:8: error: expected class-name before '{' token
make: *** [main.o] Error 1
Changing QChar to char did not alter the results at all.

Quote:
#ifndef SORTDIALOG_H
#define SORTDIALOG_H

#include <QDialog>
#include "ui_sortdialog.h"

class SortDialog : public QDialog, public Ui::SortDialog
{
Q_OBJECT

public:
SortDialog(QWidget *parent = 0);
void setColumnRange(QChar first, QChar last);
};

#endif
The error refers to line 8 instead of 16 in my case. I sub-noob when it comes to c++ so I don't even know where to begin with troubleshooting this.
 
Old 05-05-2009, 07:12 PM   #7
John VV
LQ Muse
 
Registered: Aug 2005
Location: A2 area Mi.
Posts: 17,623

Rep: Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651Reputation: 2651
it is my understanding that "qchar" is no more and the code will need to be edited to use just "char"

if the error is listed as in a *.h then where in the .cpp file is it calling that function . some function is using qchar
 
Old 05-06-2009, 12:29 PM   #8
sharky
Member
 
Registered: Oct 2002
Posts: 569

Rep: Reputation: 84
Quote:
Originally Posted by John VV View Post
it is my understanding that "qchar" is no more and the code will need to be edited to use just "char"

if the error is listed as in a *.h then where in the .cpp file is it calling that function . some function is using qchar
I changed all "QChar" in the .cpp and .h file to "char" and got the exact same error.

Quote:
In file included from main.cpp:2:
sortdialog.h:8: error: expected class-name before '{' token
make: *** [main.o] Error 1
Should I interpret from this error that "SortDialog" is not a class-name?

Code:
#ifndef SORTDIALOG_H
#define SORTDIALOG_H

#include <QDialog>
#include "ui_sortdialog.h"

class SortDialog : public QDialog, public Ui::SortDialog
{
  Q_OBJECT

public:
    SortDialog(QWidget *parent = 0);
    void setColumnRange(char first, char last);
};

#endif
 
  


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
where is FILE structure declared? vipul jain Programming 3 11-09-2008 01:36 AM
N/w card declared as not existing prabhatsoni Linux - Software 0 09-28-2007 12:20 AM
LXer: War declared LXer Syndicated Linux News 0 02-16-2006 09:31 AM
errno.h, but it IS declared...... privateprimate Linux - Software 3 09-08-2004 07:37 PM
Apache 2.0.35 declared stable jeremy Linux - General 4 04-10-2002 11:56 PM

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

All times are GMT -5. The time now is 01:32 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