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 ...
class Barverkauf : public QDialog, public Ui::UiBarverkauf
{
Q_OBJECT
MainWindow *myMainWindow;
public:
Barverkauf( MainWindow*, QString currentUser );
// some other stuff follows ...
To copy to clipboard, switch view to plain text mode
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 ...
}
#include "barverkauf.h"
Barverkauf::Barverkauf ( MainWindow *pMainWindow, QString currentUser )
: myMainWindow( pMainWindow )
{
frameHome = new QFrame( myMainWindow->centralwidget );
setupUi( frameHome );
frameHome->show();
// some other stuff follows ...
}
To copy to clipboard, switch view to plain text mode
ui_barverkauf.h
class Ui_UiBarverkauf
{
public:
// some other stuff ...
// some other stuff ...
class Ui_UiBarverkauf
{
public:
// some other stuff ...
QTableWidget *tableWidgetBarverkauf;
// some other stuff ...
To copy to clipboard, switch view to plain text mode
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;
class ReadBarcode : public QDialog, private Ui::UiReadBarcode
{
Q_OBJECT
public:
//ReadBarcode( QWidget *parent = 0 );
ReadBarcode();
// some other stuff ...
private:
Barverkauf *barverkauf;
To copy to clipboard, switch view to plain text mode
and
readbarcode.cpp
ReadBarcode::ReadBarcode()
{
setupUi( this );
//some other stuff ...
barverkauf = new Barverkauf;
}
ReadBarcode::ReadBarcode()
{
setupUi( this );
//some other stuff ...
barverkauf = new Barverkauf;
}
To copy to clipboard, switch view to plain text mode
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 ...
void ReadBarcode::addArtikel()
// some other stuff ...
barverkauf->addPos( id, artikel, menge, einzel );
// some other stuff ...
To copy to clipboard, switch view to plain text mode
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();
class Barverkauf : public QDialog, public Ui::UiBarverkauf
{
Q_OBJECT
MainWindow *myMainWindow;
public:
Barverkauf( MainWindow*, QString currentUser );
Barverkauf();
To copy to clipboard, switch view to plain text mode
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()
{
}
#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()
{
}
To copy to clipboard, switch view to plain text mode
and a setter like this:
{
qDebug() << id;
qDebug() << artikel;
qDebug() << menge;
qDebug() << einzel;
int row = tableWidgetBarverkauf->rowCount();
qDebug() << "row" << row;
// Eine neue Reihe hinzufuegen ...
tableWidgetBarverkauf->insertRow( row );
// some other code ...
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 ...
To copy to clipboard, switch view to plain text mode
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 ...
Bookmarks