LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 01-13-2006, 10:00 AM   #46
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90

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.
 
Old 01-13-2006, 01:04 PM   #47
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
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?
 
Old 01-16-2006, 12:58 PM   #48
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
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"

class Principal: public QDialog, private Ui::PrincipalBase {
        Q_OBJECT

public:
        Principal(QDialog *parent = 0);

private slots:
        void on_btnBuscar_clicked();
        void on_btnDetener_clicked();
};
See I have the two slots.

On the .cpp:
Code:
#include "principal.h"

Principal::Principal(QDialog * parent) : QDialog(parent) {
        setupUi(parent);
}

void Principal::on_btnBuscar_clicked() {
        qWarning("btnBuscar clicked");
}

void Principal::on_btnDetener_clicked() {
        qWarning("btnDetener clicked");
}
See? Very simple and straight forward. Yet when I click on btnBuscar, there's no warning showing up in the console. :'( Is there something I have to do on the .pro file?

And I still have the problem that the application is not finishing after I close the form (the only form).

Last edited by eantoranz; 01-16-2006 at 01:07 PM.
 
Old 01-16-2006, 03:54 PM   #49
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
You need to connect the button signal clicked() with your slot.
Code:
connect(btnBuscar, SIGNAL(clicked()), this, SLOT(on_btnBuscar_clicked());
Should be something like that, for each button.
 
Old 01-16-2006, 04:47 PM   #50
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
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.
 
Old 01-16-2006, 04:57 PM   #51
Mara
Moderator
 
Registered: Feb 2002
Location: Grenoble
Distribution: Debian
Posts: 9,696

Rep: Reputation: 232Reputation: 232Reputation: 232
Interesting, I haven't seen it. Thanks (it can lead to big mess, through).
 
Old 01-16-2006, 05:06 PM   #52
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
At last something you didn't know! ;-)

Last edited by eantoranz; 01-16-2006 at 06:55 PM.
 
Old 01-17-2006, 12:37 PM   #53
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
This used to work on QT3:

Code:
qWarning("Dominio: " + dominio->text());
(dominio is a QLineEdit)

But now it doesn't work with QT4.
This is the message from make:
Code:
error: cannot cast ‘const QString’ to ‘const char*’ for argument ‘1’ for ‘void qWarning(const char*, ...)’
(or something like that, I had to translate it from spanish).
 
Old 01-17-2006, 12:42 PM   #54
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
you need to convert the whole string to a c-style string. Use the toStdString() method of the QString class.
 
Old 01-17-2006, 01:07 PM   #55
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
...Or you can use the new QMessageBox class

Code:
QMessageBox::information(this
                        ,"Application name here"
                        ,"Dominio: " + dominio->text());
graeme.
 
Old 01-17-2006, 01:33 PM   #56
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Unhappy

That would be ok, but I just want a message to show up in my console, not in a window. I made the change you suggested before, and now the compiler says it can't convert from std::string to char *. It's ok if I just comment those lines (by now)... they're just debugging messages, no big deal (again, by now)... but look at this next problem (and this has me ):

Code:
int i = 0;
while (query.next()) {
	records->setItem(i, 0, QTableWidgetItem(query.value(1).toString()));
	i++;
}
And the compiler says it can't find a matching function for QTableWidget::setItem(int&, int , QTableWidgetItem)... and please, notice the & of int&. Where does that come from? i is just an int, right?
 
Old 01-17-2006, 01:47 PM   #57
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
It is expecting the TableWidgetItem to be passed as a pointer. Don't worry about the reference the compiler does that because you have passed a variable rather than a literal. So try:

Code:
records->setItem(i, 0, &(QTableWidgetItem(query.value(1).toString())));
and you should be okay.


(If you just want some diagnostics then you can use std::string and std::cout)

graeme.

Last edited by graemef; 01-17-2006 at 02:18 PM.
 
Old 01-17-2006, 02:01 PM   #58
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
It works with "new QTableWidgetItem()" too. Thanks!

Can you give me examples of the use of std::string and std::cout?
 
Old 01-17-2006, 02:06 PM   #59
eantoranz
Senior Member
 
Registered: Apr 2003
Location: Costa Rica
Distribution: Kubuntu, Debian, Knoppix
Posts: 2,092

Original Poster
Blog Entries: 1

Rep: Reputation: 90
Oops! The linker is complaining a lot!

Code:
principal.o: in the function `Principal::btnBuscarClicked()':
principal.cpp:(.text+0x1d0): reference to `QSqlDatabase::QSqlDatabase()' undefined
principal.cpp:(.text+0x1fb): reference to `QSqlQuery::QSqlQuery(QString const&, QSqlDatabase)' undefined
principal.cpp:(.text+0x229): reference to `QSqlDatabase::~QSqlDatabase()' undefined
principal.cpp:(.text+0x28e): reference to `QSqlQuery::prepare(QString const&)' undefined
.
.
.
What did I do in my past life to deserve this punishment? :'( :-D
 
Old 01-17-2006, 02:14 PM   #60
graemef
Senior Member
 
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
Looks as if the linker is not including the QT files. You may need to check your QMake. Sorry I've not actually got access to any of my make files to see what they look like for a comparison

graeme.
 
  


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
Kdevelop/IDE Question stealth0707 Programming 10 02-21-2005 07:53 AM
simple kdevelop question laclac01 Linux - Software 0 07-23-2004 10:44 AM
Kdevelop question nny0000 Slackware 3 01-11-2004 12:46 AM
Kdevelop Question BajaNick Programming 1 10-10-2003 12:40 AM
kdevelop question skibud2 Programming 4 09-04-2003 07:07 PM

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

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