#include <QtGui>
#include "loader.h"
#include <QString>
#include <QTextStream>
#include "qextserialport.h"
#include "addDialog.h"
#include <QtGui/QApplication>
#include <QCoreApplication>
#include <QString>
#include <QTextStream>
#include <QThread>
#include <QTime>
#include <QtGlobal>
#include <qdatetime.h>
#include <QByteArray>
#include <QBitArray> // probably shouldnt use as RS232 works with bytes.
#include <QStandardItem>
#include <QStandardItemModel>
#include <QVariant>
#include <QModelIndex>
{
// for (int row = 0; row < 4; ++row) {
// for (int column = 0; column < 2; ++column) {
// QStandardItem *item = new QStandardItem(QString("%0, %1").arg(row).arg(column));
// //QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
// model->setItem(row, column, item); //This item is put in the model by using the setItem(int, int, QStandardItem*) method.
// }
// } //When I uncomment this section the Table is updated
channelsView->setModel(model);
QLabel *descriptionLabel
= new QLabel(tr
("Determines Distribution"));
QLabel *currentChannelsLabel
= new QLabel(tr
("Descriptionfor Net:"));
secondLayout->addWidget(saveButton);
secondLayout->addWidget(uploadButton);
secondLayout->addWidget(quitButton);
thirdLayout->addWidget(cloningLabel);
thirdLayout->addWidget(cloningEnabled);
mainLayout->addWidget(titleLabel, 0, 1); //The title widget (WInDows GadgET) is situated at row 0, column 1, in the grid layout.
mainLayout->addWidget(descriptionLabel, 1, 1, Qt::AlignTop);
mainLayout->addWidget(netNameLabel, 4, 0);
mainLayout->addWidget(netNameLine, 4, 1);
mainLayout->addLayout(thirdLayout,5,1);
mainLayout->addWidget(addChannelButton, 6, 1);
mainLayout->addWidget(removeChannelButton, 7, 1);
mainLayout->addWidget(channelsView, 8, 1);
mainLayout->addWidget(currentChannelsLabel, 8, 0, Qt::AlignTop);
mainLayout->addLayout(secondLayout,9,1);
setLayout(mainLayout);
setWindowTitle(tr("Unit Loader"));
QObject::connect(quitButton,
SIGNAL(clicked
()),
this, SLOT(close()));
QObject::connect(uploadButton,
SIGNAL(clicked
()),
this, SLOT(calculateRandomCode()));
QObject::connect(uploadButton,
SIGNAL(clicked
()),
this, SLOT(send()));
QObject::connect(addChannelButton,
SIGNAL(clicked
()),
// So I click the addChannel button and the addChannel Dialog opens this, SLOT(addChannelDialog())); // So I click the addChannel button and the addChannel Dialog opens
}
void Loader::addChannelDialog() // the addChannelDialog SLOT or Function..
{
AddDialog *dialog = new AddDialog(this); // Creates a new object; *dialog of class AddDialog
dialog->show(); //Shows the dialog..
QObject::connect(dialog,
SIGNAL(addThisChannel
()),
this, SLOT(addChannelToTable()));
}
void Loader::addChannelToTable() // I want this SLOT to be activated when the addButton (from the AddDialog::dialog object) is clicked.
{
this,
tr("Yes,"),
tr("It works.") );
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 2; ++column) {
model->setItem(row, column, item); //This item is put in the model by using the setItem(int, int, QStandardItem*) method.
}
} // I think my problem is in the line above or below.
channelsView->setModel(model);
}
void Loader::send()
{
}
void Loader::calculateRandomCode()
{
}
#include <QtGui>
#include "loader.h"
#include <QString>
#include <QTextStream>
#include "qextserialport.h"
#include "addDialog.h"
#include <QtGui/QApplication>
#include <QCoreApplication>
#include <QString>
#include <QTextStream>
#include <QThread>
#include <QTime>
#include <QtGlobal>
#include <qdatetime.h>
#include <QByteArray>
#include <QBitArray> // probably shouldnt use as RS232 works with bytes.
#include <QStandardItem>
#include <QStandardItemModel>
#include <QVariant>
#include <QModelIndex>
Loader::Loader(QWidget *parent)
: QWidget(parent)
{
QTableView *channelsView = new QTableView();
QStandardItemModel *model = new QStandardItemModel(4,2);
// for (int row = 0; row < 4; ++row) {
// for (int column = 0; column < 2; ++column) {
// QStandardItem *item = new QStandardItem(QString("%0, %1").arg(row).arg(column));
// //QStandardItem *item = new QStandardItem(QString("row %0, column %1").arg(row).arg(column));
// model->setItem(row, column, item); //This item is put in the model by using the setItem(int, int, QStandardItem*) method.
// }
// } //When I uncomment this section the Table is updated
channelsView->setModel(model);
QLabel *titleLabel = new QLabel(tr("COMMUNICATIONS"));
QLabel *descriptionLabel = new QLabel(tr("Determines Distribution"));
QLabel *netNameLabel = new QLabel(tr("Net Name:"));
QLabel *currentChannelsLabel = new QLabel(tr("Descriptionfor Net:"));
QLabel *cloningLabel = new QLabel(tr("Enable Cloning"));
netNameLine = new QLineEdit;
currentChannelsText = new QTextEdit;
QPushButton *saveButton = new QPushButton(tr("Save Configuration Data As..."));
QPushButton *uploadButton = new QPushButton(tr("Upload Configuration "));
QPushButton *quitButton = new QPushButton(tr("Quit"));
QPushButton *addChannelButton = new QPushButton(tr("Add Channel")); // the 'tr' is for translate...
QPushButton *removeChannelButton = new QPushButton(tr("Remove Channel"));
QCheckBox *cloningEnabled = new QCheckBox();
QHBoxLayout *secondLayout = new QHBoxLayout();
secondLayout->addWidget(saveButton);
secondLayout->addWidget(uploadButton);
secondLayout->addWidget(quitButton);
QHBoxLayout *thirdLayout = new QHBoxLayout();
thirdLayout->addWidget(cloningLabel);
thirdLayout->addWidget(cloningEnabled);
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(titleLabel, 0, 1); //The title widget (WInDows GadgET) is situated at row 0, column 1, in the grid layout.
mainLayout->addWidget(descriptionLabel, 1, 1, Qt::AlignTop);
mainLayout->addWidget(netNameLabel, 4, 0);
mainLayout->addWidget(netNameLine, 4, 1);
mainLayout->addLayout(thirdLayout,5,1);
mainLayout->addWidget(addChannelButton, 6, 1);
mainLayout->addWidget(removeChannelButton, 7, 1);
mainLayout->addWidget(channelsView, 8, 1);
mainLayout->addWidget(currentChannelsLabel, 8, 0, Qt::AlignTop);
mainLayout->addLayout(secondLayout,9,1);
setLayout(mainLayout);
setWindowTitle(tr("Unit Loader"));
QObject::connect(quitButton, SIGNAL(clicked()),
this, SLOT(close()));
QObject::connect(uploadButton, SIGNAL(clicked()),
this, SLOT(calculateRandomCode()));
QObject::connect(uploadButton, SIGNAL(clicked()),
this, SLOT(send()));
QObject::connect(addChannelButton, SIGNAL(clicked()), // So I click the addChannel button and the addChannel Dialog opens
this, SLOT(addChannelDialog())); // So I click the addChannel button and the addChannel Dialog opens
}
void Loader::addChannelDialog() // the addChannelDialog SLOT or Function..
{
AddDialog *dialog = new AddDialog(this); // Creates a new object; *dialog of class AddDialog
dialog->show(); //Shows the dialog..
QObject::connect(dialog, SIGNAL(addThisChannel()),
this, SLOT(addChannelToTable()));
}
void Loader::addChannelToTable() // I want this SLOT to be activated when the addButton (from the AddDialog::dialog object) is clicked.
{
QMessageBox::information(
this,
tr("Yes,"),
tr("It works.") );
for (int row = 0; row < 4; ++row) {
for (int column = 0; column < 2; ++column) {
QStandardItem *item = new QStandardItem(QString("%0, %1").arg(row).arg(column));
model->setItem(row, column, item); //This item is put in the model by using the setItem(int, int, QStandardItem*) method.
}
} // I think my problem is in the line above or below.
channelsView->setModel(model);
}
void Loader::send()
{
}
void Loader::calculateRandomCode()
{
}
To copy to clipboard, switch view to plain text mode
Bookmarks