Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 2

Qt-interest Archive, August 2007
(Qt4.1.1,eclipse europa,macosX)the main window appears,but empty


Message 1 in thread

Hello,

I have written the beginning of a program and the test of the main
window fails.

I have created a mainwindow named init.ui, which contains:

------ OBJECT -----!!------ CLASS -----------
MainWindow		QMainWindow			
-centralwidget		QWidget				
--splitter		QSplitter			
---groupBox		QGroupBox			
----ajouter_auteur	QPushButton				
----modifier_auteur	QPushButton				
----supprimer_auteur	QPushButton			
---groupBox_2		QGroupBox			
----ajouter_livres	QPushButton					
----modifier_livres	QPushButton				
----supprimer_livres	QPushButton			
---lancer_recherche	QToolButton				
--statusBar		QStatusBar				

the code related to it is:

------------  init.h -----------------
#pragma once

#include <QMainWindow>


class init : public QMainWindow{
	Q_OBJECT
	
public:
	init();
	
protected:
	void closeEvent (QCloseEvent* event);

private slots:
	//renvoie void?
	void on_modifier_auteurs_clicked();
	void on_ajouter_auteurs_clicked();
	void on_supprimer_auteurs_clicked();
	void on_modifier_livres_clicked();
	void on_ajouter_livres_clicked();
	void on_supprimer_livres_clicked();
	void on_lancer_recherche_clicked();			
	
	
};

------------- init.h -----------------

and the file init.cpp:


------------- init.cpp ---------------
#include <QtGui>

#include "init.h"


init::init (){
	
	
}

void init::on_ajouter_auteurs_clicked(){
	QLabel* label=new QLabel("Hello!");
	label->show();
}

void init::on_modifier_auteurs_clicked(){
	
}

void init::on_supprimer_auteurs_clicked(){
	
}

void init::on_ajouter_livres_clicked(){
	
}

void init::on_modifier_livres_clicked(){
	
}

void init::on_supprimer_livres_clicked(){
	
}

void init::on_lancer_recherche_clicked(){
	
}

void init::closeEvent(QCloseEvent* event){
	event->accept();
}




------------- init.cpp ---------------

I have not created some link between signals and slots: I wanted to use
the default names (such as on_widget_clicked() ).

The C++ project consists for the moment in the mainwindow C++ files
(init.h, init.cpp) and the central C++ file, librairie.cpp.

here is the code of librairie.cpp:

----------------  librairie.cpp -------------------

#include <QApplication>

//#include "declarations.h"
#include "init.h"

int main(int argc, char *argv[])
     {


         QApplication app(argc, argv);
         init mainWin;
         mainWin.show();
         return app.exec();
     }


----------------  librairie.cpp -------------------


The program shows the mainwindow, and creates a dialog window when you
click on the "ajouter_auteur" button.

Now, you have all the elements, you can play to the doctor if you want!
Hope that you will do!

lolveley.









--
 [ signature omitted ] 

Message 2 in thread

Hello,

include ui_init.h (as provided from uic) and run setupUi(this) in the 
constuctor of the init.cpp.

Then it will work.

Greets
Jens
lolveley wrote:
> Hello,
>
> I have written the beginning of a program and the test of the main
> window fails.
>
> I have created a mainwindow named init.ui, which contains:
>
> ------ OBJECT -----!!------ CLASS -----------
> MainWindow        QMainWindow           
> -centralwidget        QWidget               
> --splitter        QSplitter           
> ---groupBox        QGroupBox           
> ----ajouter_auteur    QPushButton               
> ----modifier_auteur    QPushButton               
> ----supprimer_auteur    QPushButton           
> ---groupBox_2        QGroupBox           
> ----ajouter_livres    QPushButton                   
> ----modifier_livres    QPushButton               
> ----supprimer_livres    QPushButton           
> ---lancer_recherche    QToolButton               
> --statusBar        QStatusBar               
>
> the code related to it is:
>
> ------------  init.h -----------------
> #pragma once
>
> #include <QMainWindow>
>
>
> class init : public QMainWindow{
>     Q_OBJECT
>     
> public:
>     init();
>     
> protected:
>     void closeEvent (QCloseEvent* event);
>
> private slots:
>     //renvoie void?
>     void on_modifier_auteurs_clicked();
>     void on_ajouter_auteurs_clicked();
>     void on_supprimer_auteurs_clicked();
>     void on_modifier_livres_clicked();
>     void on_ajouter_livres_clicked();
>     void on_supprimer_livres_clicked();
>     void on_lancer_recherche_clicked();           
>     
>     
> };
>
> ------------- init.h -----------------
>
> and the file init.cpp:
>
>
> ------------- init.cpp ---------------
> #include <QtGui>
>
> #include "init.h"
>
>
> init::init (){
>     
>     
> }
>
> void init::on_ajouter_auteurs_clicked(){
>     QLabel* label=new QLabel("Hello!");
>     label->show();
> }
>
> void init::on_modifier_auteurs_clicked(){
>     
> }
>
> void init::on_supprimer_auteurs_clicked(){
>     
> }
>
> void init::on_ajouter_livres_clicked(){
>     
> }
>
> void init::on_modifier_livres_clicked(){
>     
> }
>
> void init::on_supprimer_livres_clicked(){
>     
> }
>
> void init::on_lancer_recherche_clicked(){
>     
> }
>
> void init::closeEvent(QCloseEvent* event){
>     event->accept();
> }
>
>
>
>
> ------------- init.cpp ---------------
>
> I have not created some link between signals and slots: I wanted to use
> the default names (such as on_widget_clicked() ).
>
> The C++ project consists for the moment in the mainwindow C++ files
> (init.h, init.cpp) and the central C++ file, librairie.cpp.
>
> here is the code of librairie.cpp:
>
> ----------------  librairie.cpp -------------------
>
> #include <QApplication>
>
> //#include "declarations.h"
> #include "init.h"
>
> int main(int argc, char *argv[])
>     {
>
>
>         QApplication app(argc, argv);
>         init mainWin;
>         mainWin.show();
>         return app.exec();
>     }
>
>
> ----------------  librairie.cpp -------------------
>
>
> The program shows the mainwindow, and creates a dialog window when you
> click on the "ajouter_auteur" button.
>
> Now, you have all the elements, you can play to the doctor if you want!
> Hope that you will do!
>
> lolveley.
>
>
>
>
>
>
>
>
>
> -- 
> To unsubscribe - send a mail to qt-interest-request@xxxxxxxxxxxxx with 
> "unsubscribe" in the subject or the body.
> List archive and information: http://lists.trolltech.com/qt-interest/
>
>
>


--
 [ signature omitted ]