[an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive] (none) [an error occurred while processing this directive] [an error occurred while processing this directive] [an error occurred while processing this directive][an error occurred while processing this directive]
 
[an error occurred while processing this directive] [an error occurred while processing this directive]
Skåne Sjælland Linux User Group - http://www.sslug.dk Home   Subscribe   Mail Archive   Forum   Calendar   Search
MhonArc Date: [Date Prev] [Date Index] [Date Next]   Thread: [Date Prev] [Thread Index] [Date Next]   MhonArc
 

Qt-problem...



Hejsan!!

Jag håller på att lära mig C++ och då programmering med Qt. 
Nu har jag en liten fråga: Hur får jag en funktion till en knapp i sourcen som jag skickar med??

Det är ett enkelt "Hello World" exempel (fast på svenska ;). Där är en label och 2 knappar. Hur gör jag för att få
knappen som har texten "Hejsan världen" att göra något enkelt?? Kanske bara ändra texten på Labelen eller något??

(jag kan inte programmera så bra inu, så skratta gärna åt sourcen, men hjälp mig då och visa hur man kan förbättra
den... ;)

Kompilera sourcen med följande kommando:  "g++ -c -I/usr/lib/qt//include -pipe -O2 -fno-strength-reduce -o Qttest.o
qttest.cc -Wall ; g++ -L/usr/lib/qt//lib -L/usr/X11R6/lib  -o Qttest Qttest.o  -lqt -lX11 -lXext -Wall"
#include <qpushbutton.h>
#include <qwindow.h>
#include <qlabel.h>
#include <qbitmap.h>
#include <qapplication.h>
#include <qfont.h>
#include <qdatetime.h>
#include <time.h>
#include <iostream.h>
#include <stdlib.h>

// #include <qmenubar.h>                                 // För framtida bruk ;)

class mittprogram : public QWindow
{
public:
  mittprogram();

private:
  QPushButton *restart;
};

mittprogram::mittprogram()
{
  resize(270,200);
  setMinimumSize(270, 200);
  setMaximumSize(270, 201);
  setCaption("Johans Qt-test-program ");
}

int main(int argc, char **argv)
{
  QApplication a(argc, argv);
  mittprogram v;
  QPushButton test(" Avsluta ", &v);
  test.move(100, 50);
  test.resize(75, 30);
  QObject::connect(&test, SIGNAL(clicked()), &a, SLOT(quit()));
  QPushButton test2(" Hejsan Världen ", &v);
  srand(time(NULL));
  test2.move(rand() % 130, rand() % 130);
  test2.resize(100, 40);
  QObject::connect(&test2, SIGNAL(clicked()), &a, SLOT(quit()));

  QLabel testlabel(" Hejsan universum!! ", &v);
  testlabel.move(30,90);
  testlabel.resize(140,20);

  a.setMainWidget(&v);
  v.show();
  return a.exec();
}


 
Home   Subscribe   Mail Archive   Index   Calendar   Search

 
 
Questions about the web-pages to <www_admin>. Last modified 2005-08-10, 20:07 CEST [an error occurred while processing this directive]
This page is maintained by [an error occurred while processing this directive]MHonArc [an error occurred while processing this directive] # [an error occurred while processing this directive] *