.ui.h / kdevelop question
I think I got the concept right. I have to use a .ui.h file to make (and code) my own slots. That's OK. But where do I have to code, say a Dialog's constructor? because the .cpp file, and .h and moc.h files are re-created everytime I build the project, so it doesn't make sense to write any code there.
What do you think? |
The method most people use (including me) is to write the new class (that inherites the one created in Designer) in a new set of .h and .cpp files (header and implementation). Then you can just #include the orginal header and it can be overwritten by uic without any problems. The rule is: don't modify the files build by automatic tools.
|
OK.... I'm starting to work on that.
I had a UI called "Principal", and I was able to compile it without a problem. I changed its name to PrincipalBase, created a file called principal.h that I will use to extend PrincipalBase, the problem is that I can't build now. :'( This is the content of principal.h (in case I made a mistake on the extension): Code:
#include "principalbase.h" Code:
attention: commands are imposed for the target "principalbase.h" Any idea of what I'm doing wrong? :scratch: |
You need to run 'uic' on the .ui file (clear the project, then build again). Also, make sure that the whole class is renamed, not only the header file.
|
When I start kdevelop, it gets stuck switching between two of the file tabs that I had opened before I closed kdevelop the last time and I can't do anything at all. How can I keep it from happening? :mad:
|
Your KDevelop config is kept in ~/.kde/share/config/kdevelop3rc. If you delete it, you get the default config.
In your case it may be easier to edit last session. If probect is someproject/ and has someproject/someproject.kdevelop, you need to edit/remove someproject/someproject.kdevses |
I did something a little less radical. I removed the last doc in the project's .kdevses file. That did the trick.
Will keep you posted about my advances... and Thanks, Mara! |
I managed (somehow, don't ask :-) ) to extend my original class and make the two QDateEdit fields to have today's date as their date. However, I am starting to miss code completion, and I also had to manually add the .h filed needed as includes (qdatetime.h, qdatetimeedit.h), and that's certainly not the kind of work I want to do (I-m thinking about coing java in eclipse, right now). Is it possible to make kdevelop code-complete as I write? and also that it automagically adds/removes header files as needed?
|
I'm wondering how you're adding the new classes. Do as much as possible in Designer, the include its' files, they have all the needed includes (usually).
Also, if you have't already, look into Project Options->C++ specific->Code completion You can add your own code completion databases. |
I extended the hard way. Created two new files: form.h and form.cpp and wrote all the code there. What's the "lazy" way?
|
'Generate new class' button on on the right side (below 'Open project') or Project->New class
|
Mara, you have been very helpful! I appreciate that! :-)
Do you know how I can build (or maybe install through apt) QT's MySQL Plugin? I'm on a kubuntu breezy box... boxes, as a matter of fact. ;-) |
Quote:
Code:
./configure -plugin-sql-mysql |
oops REMOVED same as above..
page not refreshing or even *reacting* when hitting submit.. ?? @moderator.. delete me ??? |
It was a lot simpler than compiling something. There's a package for each driver.
from apt-cache search libqt3: Code:
libqt3-mt-ibase - InterBase/FireBird database driver for Qt3 (Threaded) Code:
apt-get install libqt3-mt-mysql |
I'm on the Database stuff right now.
What's wrong with this code? Code:
QSqlQuery query; It's a connection to a MySQL DB. |
You don't execute the query, it's only prepared. Add something like:
Code:
if(query.exec () == FALSE) { |
Mara... you ROCK! Thanks. Let's see how I advance. Will keep you posted. Thank you very much!
|
It's not directly related to kdevelop per se, but to C++, but anyway:
How can I make "correct" use of this: "There are " + query.size() + " records./n" + " Want to see them anyway?" The compiler is complaining because I'm mixing: "const char*" with "const char[n]" (being n a given number). How can I make a single String from that without having to go though a lot of hazzle? |
how about compiling in windows?
How about compiling in windows?
What things do I have to use (should use) to build my kdevelop (basically QT based) project in windows? If possible, I'd like to go clicking (just like Kdevelop) to build my project. As free an environment as possible (I mean free, beerwise and speechwise). Maybe there's Kdevelop for windows and I haven't heard yet. :-) I have no IDE / compiler installed on my machine yet. |
change
Code:
"There are " + query.size() + " records./n" + " Want to see them anyway?" Code:
"There are " + query.size() + " records./n Want to see them anyway?" |
A good C/C++ IDE for windows is DevC++ I've not tried it with QT but it should be possible. However you may need to tweek DevC++ to use the borland bcc compiler since I think that the Windows QT libraries are only compatibel with borland or MSVC.
You can also look at the borland site since I rememeber that they did release an old version of C++ Builder out to the community. graeme. |
Quote:
qmake -project something.pro qmake make That's all :) |
Am sorry for my ignorance on C / C++ development on windows:
:scratch: make is provided by windows? and for graemef: I got the same error message, only with a different n (a bigger one ;-)) |
Okay are you storing this into a QString? That is what I was expecting...
You will also need to convert the number to a QString... Code:
QString::number(query.size()) |
Let me try.... and about make: I just found out that it's included with MinGW.
Will keep you posted... stay close. :-) |
I'm trying to compile, but I get this error message:
Code:
qpopupmenu.h: No such file or directory Maybe it's the version. I'm working with QT3 on linux and I installed QT4.1.0 here on windows... is that the problem? |
Most likely you problem is with the different versions (or at least your current problem ;)) QT4 has a very different file layout and the classes are quite different. It doest have access to the old classes but they are names something like Q3BlahBlahBlah.
graeme. |
As I found no QT3 for windows, I guess I'll have to move up development on linux to QT4. Fortunately this is just a test and I can tweek as much as needed till I "figure it out".
How can I force kdevelop to use qt4? (it's a ubuntu breezy box). |
Why was I so naive to believe it was going to be so simple? :scratch:
Anyway... I'm just learning that kdevelop will probably use QT4 in their next release... but not right now. So... what should I do? Try to make windows compile qt3 code or switch to QT4 (working by hand until kdevelop4 is available? :scratch:) altogether? |
Hi,
Okay you have just reminded me that QT was not free on Windows prior to release 4. However you can use QT4 on Kdevelop, I think what you need to do is to change the QPATH variable in you bash_profile file. I think that's what I did for Fedora but I'm working on windows today so I can't check :( ... graeme. |
Quote:
Quote:
|
Here's my path:
Code:
$ echo $PATH and the other possibility: QPATH. That variable is not set in my environment. What should it be? |
Okay I didn't quite get it right, the environment variable is QTDIR...
It's set on my system as: Quote:
hope that helps graeme. |
Good! But it's not set in my environment either. :-)
|
Perhaps this can help you help me:
Code:
$ dpkg -l qt'*' |
I don't know where the package will put qt but try a slocate
Code:
$ slocate include/QtCore/QString graeme. |
I have /usr/include/qt[34]
inside /usr/include/qt4/ there's QtCore and QtCore/QString so Code:
QDIR=/usr/include/qt4/ |
and about the other problem: I finally made the "String" show up:
Code:
QString("Hay ").append(QString::number(consulta.size())).append(" registros en la consulta. Desea verlos?") |
and bad news (for me, of course). I don't have a bin inside qt4:
Code:
/usr/include/qt4$ find ./ -iname bin'*' I digged a little further: Code:
$ dpkg -L qt4-dev-tools |
The set is quite short. What you really need (apart from assistant and designer): uic, moc, qmake.
|
after a little 'update-alternatives', I have this:
Code:
$ qmake -v PS I just ran kdevelop, my old project, and asked to compile and it says: QDIR=/usr/share/qt3 and it compiled successfully. I expected it to fail big time. :scratch: |
qt3 to qt4
I thought it was gonna be an easy thing to change from qt3 to qt4, but it seems it isn't just a matter or running the new verion of qmake. I'll have to remake my very first project to see how qt4 works, cause there are many changes.
Will keep you posted. :-) Thanks for your help so far. PS I'll be working without kdevelop till I figure the whole thing out. |
some progress on QT4
I'm starting to make some progress on QT4, though not working on kdevelop, but kate, designer, konsole and so on. :'(
I have noticed two problems: When I try to make my project, it doesn't do the uic of the form I'm working on, though I included it in the src.pro file. Code:
SOURCES += main.cpp Code:
$ qmake src.pro; qmake; make If I uic it myself, going to that directory, then it works: Code:
$ cd formas/principal/ Finally, the second problem: when I run the application, it fails to stop when I close the main form. I have to ctrl+c it. Here's the main code: Code:
QApplication a( argc, argv ); |
There is a conversion program from QT3 to QT4. Not certain how accurate it is but worth running your program through that first.
graeme. |
The form I'm using was already transformed using designer (qt4) and I dropped the qt3 version from the project. The other code I had already made for the project, I'll include it (or should I say twist it) it once I get the naked frame up and running correctly. And thanks for that information. I had alredy read about it on the QT4 help pages.
|
I was able to make it uic the form.
The problem is that I thought it was going to compile formas/principal/formabase_qt4.ui into formas/principal/ui_formabase_qt4.h, and that was my include in main.cpp, but it uics it into ui_formabase_qt4.h (in that same directory of main.cpp). I had to change the include in main.cpp, and then it worked. Now are there any advices to make the application finish once I close the main frame? |
OK... I finally made the form show up.
I noticed there was a mistake (i think) in the tutorial that I corrected. The binary ran anyway, but the form showed up with no content. After a while looking at the code, I noticed that the extended class was calling setupUi(this) instead of setupUi(parent). I made the correction and then the frame showed up! What I'm missing now is the auto-connection. I have two buttons in my form: btnBuscar and btnDetener. On the extended .h I have: Code:
#include "ui_principalbase.h" On the .cpp: Code:
#include "principal.h" And I still have the problem that the application is not finishing after I close the form (the only form). :scratch: |
You need to connect the button signal clicked() with your slot.
Code:
connect(btnBuscar, SIGNAL(clicked()), this, SLOT(on_btnBuscar_clicked()); |
Oh, I did that in order to move on... but according to QT4 documentation uic (somehow) can do that work for me automagically. Look QT's autoconnection feature in the QT4 documentation.
|
All times are GMT -5. The time now is 02:05 AM. |