gboelter
8th November 2009, 06:36
Hello World!
I'm really sorry guys, I know that this is not really a Qt relatedt question, but I don't know any better forum where are so many C++ specialist then here ...
I have a class, it's called 'Barverkauf' and until today everything is doing well.
barverkauf.h
class Barverkauf : public QDialog, public Ui::UiBarverkauf
{
Q_OBJECT
MainWindow *myMainWindow;
public:
Barverkauf( MainWindow*, QString currentUser );
// some other stuff follows ...
barverkauf.cpp
#include "barverkauf.h"
Barverkauf::Barverkauf ( MainWindow *pMainWindow, QString currentUser )
: myMainWindow( pMainWindow )
{
frameHome = new QFrame( myMainWindow->centralwidget );
setupUi( frameHome );
frameHome->show();
// some other stuff follows ...
}
ui_barverkauf.h
class Ui_UiBarverkauf
{
public:
// some other stuff ...
QTableWidget *tableWidgetBarverkauf;
// some other stuff ...
May be the code is not pefect - I'm still a beginner - but I can add, edit and delete lines to/from the tableWidgetBarverkauf very well..
But then I've tried to implement a barcode-reader, and now I have a problem:
I've created:
readbarcode.h
class ReadBarcode : public QDialog, private Ui::UiReadBarcode
{
Q_OBJECT
public:
//ReadBarcode( QWidget *parent = 0 );
ReadBarcode();
// some other stuff ...
private:
Barverkauf *barverkauf;
and
readbarcode.cpp
ReadBarcode::ReadBarcode()
{
setupUi( this );
//some other stuff ...
barverkauf = new Barverkauf;
}
Here i've tried to call the setter in barverkauf.cpp ...
void ReadBarcode::addArtikel()
// some other stuff ...
barverkauf->addPos( id, artikel, menge, einzel );
// some other stuff ...
Then I've added a second constructor to class Barverkauf like this:
barverkauf.h
class Barverkauf : public QDialog, public Ui::UiBarverkauf
{
Q_OBJECT
MainWindow *myMainWindow;
public:
Barverkauf( MainWindow*, QString currentUser );
Barverkauf();
barverkauf.cpp
#include "barverkauf.h"
Barverkauf::Barverkauf ( MainWindow *pMainWindow, QString currentUser )
: myMainWindow( pMainWindow )
{
frameHome = new QFrame( myMainWindow->centralwidget );
setupUi( frameHome );
frameHome->show();
// some other stuff follows ...
}
Barverkauf::Barverkauf()
{
}
and a setter like this:
void Barverkauf::addPos( QString id, QString artikel, QString menge, QString einzel )
{
qDebug() << id;
qDebug() << artikel;
qDebug() << menge;
qDebug() << einzel;
int row = tableWidgetBarverkauf->rowCount();
qDebug() << "row" << row;
// Eine neue Reihe hinzufuegen ...
tableWidgetBarverkauf->insertRow( row );
tableWidgetBarverkauf->setItem( row, 0, new QTableWidgetItem() );
tableWidgetBarverkauf->setItem( row, 1, new QTableWidgetItem() );
// some other code ...
Looks like the code is working now, but the lines are added to the second tableWidgetBarverkauf I have created in my copy-constructor.
In other words, it's working, but I can't see it on the screen!
Sorry, but I've never worked with a second constructor before ...
I'm really sorry guys, I know that this is not really a Qt relatedt question, but I don't know any better forum where are so many C++ specialist then here ...
I have a class, it's called 'Barverkauf' and until today everything is doing well.
barverkauf.h
class Barverkauf : public QDialog, public Ui::UiBarverkauf
{
Q_OBJECT
MainWindow *myMainWindow;
public:
Barverkauf( MainWindow*, QString currentUser );
// some other stuff follows ...
barverkauf.cpp
#include "barverkauf.h"
Barverkauf::Barverkauf ( MainWindow *pMainWindow, QString currentUser )
: myMainWindow( pMainWindow )
{
frameHome = new QFrame( myMainWindow->centralwidget );
setupUi( frameHome );
frameHome->show();
// some other stuff follows ...
}
ui_barverkauf.h
class Ui_UiBarverkauf
{
public:
// some other stuff ...
QTableWidget *tableWidgetBarverkauf;
// some other stuff ...
May be the code is not pefect - I'm still a beginner - but I can add, edit and delete lines to/from the tableWidgetBarverkauf very well..
But then I've tried to implement a barcode-reader, and now I have a problem:
I've created:
readbarcode.h
class ReadBarcode : public QDialog, private Ui::UiReadBarcode
{
Q_OBJECT
public:
//ReadBarcode( QWidget *parent = 0 );
ReadBarcode();
// some other stuff ...
private:
Barverkauf *barverkauf;
and
readbarcode.cpp
ReadBarcode::ReadBarcode()
{
setupUi( this );
//some other stuff ...
barverkauf = new Barverkauf;
}
Here i've tried to call the setter in barverkauf.cpp ...
void ReadBarcode::addArtikel()
// some other stuff ...
barverkauf->addPos( id, artikel, menge, einzel );
// some other stuff ...
Then I've added a second constructor to class Barverkauf like this:
barverkauf.h
class Barverkauf : public QDialog, public Ui::UiBarverkauf
{
Q_OBJECT
MainWindow *myMainWindow;
public:
Barverkauf( MainWindow*, QString currentUser );
Barverkauf();
barverkauf.cpp
#include "barverkauf.h"
Barverkauf::Barverkauf ( MainWindow *pMainWindow, QString currentUser )
: myMainWindow( pMainWindow )
{
frameHome = new QFrame( myMainWindow->centralwidget );
setupUi( frameHome );
frameHome->show();
// some other stuff follows ...
}
Barverkauf::Barverkauf()
{
}
and a setter like this:
void Barverkauf::addPos( QString id, QString artikel, QString menge, QString einzel )
{
qDebug() << id;
qDebug() << artikel;
qDebug() << menge;
qDebug() << einzel;
int row = tableWidgetBarverkauf->rowCount();
qDebug() << "row" << row;
// Eine neue Reihe hinzufuegen ...
tableWidgetBarverkauf->insertRow( row );
tableWidgetBarverkauf->setItem( row, 0, new QTableWidgetItem() );
tableWidgetBarverkauf->setItem( row, 1, new QTableWidgetItem() );
// some other code ...
Looks like the code is working now, but the lines are added to the second tableWidgetBarverkauf I have created in my copy-constructor.
In other words, it's working, but I can't see it on the screen!
Sorry, but I've never worked with a second constructor before ...