473,385 Members | 1,873 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problems about Qt signals and compilation errors

2
Hi all !

Well, I am working for my first time in life with Qt libs and I have a few problems.

First, I want to make a QApplication very simple to practise signal/slots functionality.

The idea is: A QFrame with 1 Qlabel, 1QPushbutton and 1 QLineEdit. When you write something in the line edit, it is printed ( char by char) on the label. The button is used to exit ( close()). Quite easy.

Second exercise: the same thing but now, if you write something, it is displayed on the label with capital letters the even chars and normal letters the odd.

So I need to specialise QLabel with a new class that inherits from it, with a new slot setText(const QString &).

Here is my code:

#include <QString>
#include <QObject>
#include <QLabel>

class QLabelMM : public QLabel {

Q_OBJECT

public:

LabelMM();

public slots:

void setTextMM( const QString &text){

//const QString str = text;

for(int i = 0; i < text.length(); i++)
{
if(i%2 == 0) text.data()[i] = text.data()[i] +20;
}
}


}

Don't bother about macros like Q_OBJECT, qmake takes care of it.

And my errors: lab1.cpp:23: error: expected unqualified-id at end of input (line 23 is the "}" that closes the slot

Any thoughts that what is failing?

Another thing is that I don't think that is correct the way I pass from capitals to normals (text.data()[i] +20) but that is another question that I hope to resolve on my own :p!
Sep 22 '08 #1
1 1297
newb16
687 512MB
Another thing is that I don't think that is correct the way I pass from capitals to normals (text.data()[i] +20) but that is another question that I hope to resolve on my own :p!
Last time I used it, qt was moc-ing only .h files , but not .cpp - did it change now? If not, move declaration to .h and definition to .cpp. And, not qt-specifical, if you declared text argument as "const Qstring&", why do you change text.data in function? Pass it by value, textMM(QString text) and then modify.
Sep 23 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Richard Taylor | last post by:
User-Agent: OSXnews 2.07 Xref: number1.nntp.dca.giganews.com comp.lang.python:437315 Hi I am trying to use py2app (http://undefined.org/python/) to package a gnome-python application...
5
by: Lili | last post by:
I'm having problems creating a simple stored procedure in DB2. Can someone help? Here is the screen dump when I tried to load the stored procedure. Thanks for any help. Create procedure...
2
by: FireStarter | last post by:
Guys, in the code that follows, why does the method F() still compile, even if DBG is undefined? Inside method G(), the code inside <#if DBG> does not compile (notice that I can write whatever I...
2
by: Joel D. Kraft | last post by:
I've been very happy with the performance and new features of my site since we converted to ASP.NET 2.0 beta 2. I have noticed a couple of interesting problems, though, which I am trying to...
0
by: Vidyasagara Guntaka | last post by:
Hi, I recently downloaded source code for 8.0.0 beta1. When I tried building the libpq for windows, I got some compilation errors. Following the compilation output:...
27
by: CTI | last post by:
I got problems when I want to make a MDE file. The app. got a lack of memory. Bart Access 2003
6
by: alban | last post by:
Hello I have got some problems of compilation on a AIX IBM, I use the XLC compilator (And I can't install another one). I try to compile code Pro*c ".pc" (oracle), I need do a pre-compilation...
11
by: alnoir | last post by:
I'm using the Open Perl IDE to write perl scripts. Everytime I try to compile a script Open Perl will open another script called 'perl5db.pl' and find a compiling error in it. The result in the...
35
by: mwelsh1118 | last post by:
Why doesn't C# allow incremental compilation like Java? Specifically, in Java I can compile single .java files in isolation. The resulting individual .class files can be grouped into .jar files....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.