hallo,
ich nutze den qtdesigner um meine oberfläche zu erstellen. wenn ich nun die cpp datei von hand manipuliere wird das beim nächsten compilieren wieder rückgängig gemacht, da die datei auf die ui datei zugreift.
kann mir jemand sagen, wie ich das mit dem designer bewerkstelligen kann und wie man die zeit ausliesst.
danke!
uhrzeit im label darstellen
http://doc.trolltech.com/4.2/designer-c ... ilder.html
bzw.
http://doc.trolltech.com/4.2/designer-c ... rform.html
bzw.
http://doc.trolltech.com/4.2/designer-c ... rform.html
Code: Alles auswählen
QTime QTime::currentTime ()
ok..
jetzt hab ich nur das problem wie wohl manch anderer auch, das ich nicht weiss wohin damit.. ich hab ein project mit dem designer erstellt, wo eine main.cpp drin ist mit folgenden inhalt
dann hab ich noch eine form1.cpp mit einigen objekten.. die sieht folgendermaßen aus.
in dieses textLabel1_2 möchte ich die zeit ausgeben lassen.
danke für die hilfe
jetzt hab ich nur das problem wie wohl manch anderer auch, das ich nicht weiss wohin damit.. ich hab ein project mit dem designer erstellt, wo eine main.cpp drin ist mit folgenden inhalt
Code: Alles auswählen
#include <qapplication.h>
#include "form1.h"
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
Form1 w;
w.show();
a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
return a.exec();
}
Code: Alles auswählen
#include "form1.h"
#include <qvariant.h>
#include <qframe.h>
#include <qradiobutton.h>
#include <qpushbutton.h>
#include <qlabel.h>
#include <qlineedit.h>
#include <qlcdnumber.h>
#include <qslider.h>
#include <qlistbox.h>
#include <qlayout.h>
#include <qtooltip.h>
#include <qwhatsthis.h>
#include <qimage.h>
#include <qpixmap.h>
#include "form1.ui.h"
/*
* Constructs a Form1 as a child of 'parent', with the
* name 'name' and widget flags set to 'f'.
*
* The dialog will by default be modeless, unless you set 'modal' to
* TRUE to construct a modal dialog.
*/
Form1::Form1( QWidget* parent, const char* name, bool modal, WFlags fl )
: QDialog( parent, name, modal, fl )
{
if ( !name )
setName( "Form1" );
line4 = new QFrame( this, "line4" );
line4->setGeometry( QRect( 20, 250, 330, 20 ) );
line4->setFrameShape( QFrame::HLine );
line4->setFrameShadow( QFrame::Sunken );
line4->setFrameShape( QFrame::HLine );
radioButton1 = new QRadioButton( this, "radioButton1" );
radioButton1->setEnabled( TRUE );
radioButton1->setGeometry( QRect( 100, 270, 16, 22 ) );
line1 = new QFrame( this, "line1" );
line1->setGeometry( QRect( 20, 150, 330, 20 ) );
line1->setFrameShape( QFrame::HLine );
line1->setFrameShadow( QFrame::Sunken );
line1->setFrameShape( QFrame::HLine );
textButton2 = new QPushButton( this, "textButton2" );
textButton2->setEnabled( FALSE );
textButton2->setGeometry( QRect( 200, 210, 108, 34 ) );
textLabel2 = new QLabel( this, "textLabel2" );
textLabel2->setGeometry( QRect( 210, 270, 80, 20 ) );
textButton1 = new QPushButton( this, "textButton1" );
textButton1->setEnabled( FALSE );
textButton1->setGeometry( QRect( 40, 210, 108, 34 ) );
textButton1->setFlat( FALSE );
lineEdit1 = new QLineEdit( this, "lineEdit1" );
lineEdit1->setGeometry( QRect( 20, 170, 140, 25 ) );
textLabel1 = new QLabel( this, "textLabel1" );
textLabel1->setGeometry( QRect( 180, 170, 170, 30 ) );
lCDNumber1 = new QLCDNumber( this, "lCDNumber1" );
lCDNumber1->setGeometry( QRect( 20, 10, 330, 110 ) );
lCDNumber1->setPaletteBackgroundColor( QColor( 0, 170, 0 ) );
lCDNumber1->setSegmentStyle( QLCDNumber::Filled );
slider1 = new QSlider( this, "slider1" );
slider1->setGeometry( QRect( 20, 120, 330, 24 ) );
slider1->setMaxValue( 100 );
slider1->setOrientation( QSlider::Horizontal );
textLabel3 = new QLabel( this, "textLabel3" );
textLabel3->setGeometry( QRect( 20, 340, 120, 30 ) );
listBox1 = new QListBox( this, "listBox1" );
listBox1->setGeometry( QRect( 160, 310, 190, 90 ) );
textLabel1_2 = new QLabel( this, "textLabel1_2" );
textLabel1_2->setGeometry( QRect( 40, 420, 75, 20 ) );
languageChange();
resize( QSize(368, 467).expandedTo(minimumSizeHint()) );
clearWState( WState_Polished );
// signals and slots connections
connect( slider1, SIGNAL( valueChanged(int) ), lCDNumber1, SLOT( display(int) ) );
connect( textButton1, SIGNAL( clicked() ), this, SLOT( textchange() ) );
connect( radioButton1, SIGNAL( stateChanged(int) ), this, SLOT( checker() ) );
connect( listBox1, SIGNAL( currentChanged(QListBoxItem*) ), this, SLOT( listitem() ) );
connect( textButton2, SIGNAL( clicked() ), this, SLOT( textdelete() ) );
}
/*
* Destroys the object and frees any allocated resources
*/
Form1::~Form1()
{
// no need to delete child widgets, Qt does it all for us
}
/*
* Sets the strings of the subwidgets using the current
* language.
*/
void Form1::languageChange()
{
setCaption( trUtf8( "\x54\x6f\x6d\x6d\x79\x73\x20\x54\x65\x73\x74\x75\x6d\x67\x65\x62\x75\x6e\x67\x20\x66"
"\xc3\xbc\x72\x20\x51\x54\x20\x3b\x2d\x29" ) );
radioButton1->setText( QString::null );
textButton2->setText( trUtf8( "\x54\x65\x78\x74\x20\x6c\xc3\xb6\x73\x63\x68\x65\x6e" ) );
textLabel2->setText( tr( "nicht aktiv" ) );
textButton1->setText( trUtf8( "\x54\x65\x78\x74\x20\xc3\xa4\x6e\x64\x65\x72\x6e" ) );
textLabel1->setText( trUtf8( "\x64\x65\x72\x20\x74\x65\x78\x74\x20\xc3\xa4\x6e\x64\x65\x72\x74\x20\x73\x69\x63\x68"
"" ) );
textLabel3->setText( tr( "Eintragsnr.:" ) );
listBox1->clear();
listBox1->insertItem( tr( "Eintrag eins" ) );
listBox1->insertItem( tr( "Eintrag zwei" ) );
listBox1->insertItem( tr( "Eintrag drei" ) );
listBox1->insertItem( tr( "Eintrag vier" ) );
listBox1->setCurrentItem( 0 );
textLabel1_2->setText( tr( "textLabel1" ) );
}
danke für die hilfe
ich hab es nun soweit mal hinbekommen das meine zeit auch als string konvertiert wird und in einem label ausgegeben wird.
gibt es eine möglichkeit, wie im c++ builder die zeit sekündlich aktualisieren zu lassen?
mein code
danke
gibt es eine möglichkeit, wie im c++ builder die zeit sekündlich aktualisieren zu lassen?
mein code
Code: Alles auswählen
void Form1::timeview()
{
textLabel4->setText(QTime::currentTime().toString());
}
-
Christian81
- Beiträge: 7319
- Registriert: 26. August 2004 14:11
- Wohnort: Bremen
- Kontaktdaten: