473,811 Members | 3,055 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Problems about Qt signals and compilation errors

2 New Member
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 1321
newb16
687 Contributor
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
2026
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 called gramps (http://www.gramps-project.org) for MAC OS X.
5
6056
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 update_salary (in emp_number char(6), in rate integer) language sql begin update employee
2
2589
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 want in there, I will not receive a compilation error). I do get such an error in F() - because of the garbage I intentionally put there - but F() should not compile in the first place. Am I misusing this attribute?! #undef DBG
2
5703
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 figure out. I can't confirm that they didn't exist under 1.1, but I didn't notice them at that time. My error handling is configured as follows: - In IIS, 404 errors are mapped to /site/error/404.aspx. - "Verify that file exists" is ON for .aspx...
0
1859
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: C:\temp\postgresql-8.0.0beta1\src>nmake /f win32.mak Microsoft (R) Program Maintenance Utility Version 6.00.8168.0 Copyright (C) Microsoft Corp 1988-1998. All rights reserved. cd include if not exist pg_config.h copy pg_config.h.win32 pg_config.h
27
2139
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
9805
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 after the pre-compilation with the my makefile I get the files ".c" After this a get also the objects files ".o", but no linkage ! and I can't have the exec file ! I have got some errors how I dont understand really :
11
14491
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 'Error Output' box is: Win32 does not define $Win32::VERSION--version check failed at C:\Open_Perl_IDE_1.0.11.409/perl5db.pl line 438. BEGIN failed--compilation aborted. Compilation failed in require at C:/Perl/lib/Win32.pm line 8. BEGIN...
35
3061
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. In C#, there appears to be no analog. I have to compile all my .cs files into a single .dll. This has serious drawbacks in terms of compilation. With Eclipse, I change a file and only that file is re-compiled. With Visual Studio, I
0
9731
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9605
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10651
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10393
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10136
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9208
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7671
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5556
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
3
3020
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.