#include <QDialog>
class DateListDialog
: public QDialog {Q_OBJECT
public:DateListDialog();
}
#include <QDialog>
class DateListDialog: public QDialog {
Q_OBJECT
public:DateListDialog();
}
To copy to clipboard, switch view to plain text mode
but I want to add a menubar and I am not sure how if it is a QDialog so I wish to turn the QDialog into a QMainWindow I tried changing the code on the header to:
#include <QMainWindow>
Q_OBJECT
public:DateListDialog();
}
#include <QMainWindow>
class DateListDialog: public QMainWindow {
Q_OBJECT
public:DateListDialog();
}
To copy to clipboard, switch view to plain text mode
but then when I do that and add the menubar all it shows it the menubar and not all the other gui items so basically its just an empty QMainWindow
#include <QtGui>
#include "datelistdialog.h"
#include "listwidgetdialog.h"
#include <sstream>
#include <iostream>
using namespace std;
DateListDialog::DateListDialog()
{
QStringList dates, foods, totalCalories, totalProteins, totalCarbs, totalFats, totalSugars, totalSodiums, totalFibers;
labels << tr("Dates") << tr("Foods") << tr("Total Calories") << tr("Total Proteins") << tr("Total Carbs") << tr("Total Fats") << tr("Total Sugars") << tr("Total Sodiums") << tr("Total Fibers");
treeWidget->setColumnCount(9);
treeWidget->setHeaderLabels(labels);
mainLayout->addWidget(treeWidget);
setLayout(mainLayout);
QFile file(QDir::homePath() + "/caloriecounter.txt");
input.setCodec("UTF-8");
while(!input.atEnd()){
//dates << input.readLine();
foods << input.readLine();
totalCalories << input.readLine();
totalProteins << input.readLine();
totalCarbs << input.readLine();
totalFats << input.readLine();
totalSugars << input.readLine();
totalSodiums << input.readLine();
totalFibers << input.readLine();
input.readLine();
}
}
for (int i = 0; i < foods.size(); ++i) {
//item->setText(0, dates[i]);
item->setText(1, foods[i]);
item->setText(2, totalCalories[i]);
item->setText(3, totalProteins[i]);
item->setText(4, totalCarbs[i]);
item->setText(5, totalFats[i]);
item->setText(6, totalSugars[i]);
item->setText(7,totalSodiums[i]);
item->setText(8, totalFibers[i]);
treeWidget->addTopLevelItem(item);
}
//createActions();
//createMenus();
}
#include <QtGui>
#include "datelistdialog.h"
#include "listwidgetdialog.h"
#include <sstream>
#include <iostream>
using namespace std;
DateListDialog::DateListDialog()
{
QStringList dates, foods, totalCalories, totalProteins, totalCarbs, totalFats, totalSugars, totalSodiums, totalFibers;
QStringList labels;
labels << tr("Dates") << tr("Foods") << tr("Total Calories") << tr("Total Proteins") << tr("Total Carbs") << tr("Total Fats") << tr("Total Sugars") << tr("Total Sodiums") << tr("Total Fibers");
treeWidget = new QTreeWidget;
treeWidget->setColumnCount(9);
treeWidget->setHeaderLabels(labels);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addWidget(treeWidget);
setLayout(mainLayout);
QFile file(QDir::homePath() + "/caloriecounter.txt");
if (file.open(QIODevice::ReadOnly)){
QTextStream input(&file);
input.setCodec("UTF-8");
while(!input.atEnd()){
//dates << input.readLine();
foods << input.readLine();
totalCalories << input.readLine();
totalProteins << input.readLine();
totalCarbs << input.readLine();
totalFats << input.readLine();
totalSugars << input.readLine();
totalSodiums << input.readLine();
totalFibers << input.readLine();
input.readLine();
}
}
for (int i = 0; i < foods.size(); ++i) {
QTreeWidgetItem* item = new QTreeWidgetItem;
//item->setText(0, dates[i]);
item->setText(1, foods[i]);
item->setText(2, totalCalories[i]);
item->setText(3, totalProteins[i]);
item->setText(4, totalCarbs[i]);
item->setText(5, totalFats[i]);
item->setText(6, totalSugars[i]);
item->setText(7,totalSodiums[i]);
item->setText(8, totalFibers[i]);
treeWidget->addTopLevelItem(item);
}
//createActions();
//createMenus();
}
To copy to clipboard, switch view to plain text mode
Bookmarks