私のクラスでは、Qtunes と呼ばれる iTunes 風のプログラムのフレームワークをコーディングすることになっています。3 つの ListWidget と 1 つの TableWidget を使用してこれを行うことにしました。そこで、Qt Creator で次のコードを書きました (デザイナーを使用せずに手動でコーディングすることになっています)。
#include "mainwindow.h"
#include "ui_mainwindow.h"
#include<QtGui>
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent)
// ui(new Ui::MainWindow)
//{
// ui->setupUi(this);
//}
{
genreList = new QListWidget(this);
artistList = new QListWidget(this);
albumList = new QListWidget(this);
songTable = new QTableWidget(this);
genLabel = new QLabel(this);
genLabel->setText("Genre");
artistLabel = new QLabel(this);
artistLabel->setText("Artist");
albLabel = new QLabel(this);
albLabel->setText("Album");
QHBoxLayout *labelLayout = new QHBoxLayout;
labelLayout->addWidget(genLabel);
labelLayout->addWidget(artistLabel);
labelLayout->addWidget(albLabel);
QHBoxLayout *topLayout = new QHBoxLayout;
topLayout->addWidget(genreList);
topLayout->addWidget(artistList);
topLayout->addWidget(albumList);
QHBoxLayout *bottomLayout = new QHBoxLayout;
bottomLayout->addWidget(songTable);
QVBoxLayout *mainLayout = new QVBoxLayout;
mainLayout->addLayout(labelLayout);
mainLayout->addLayout(topLayout);
mainLayout->addLayout(bottomLayout);
setLayout(mainLayout);
setWindowTitle("Version 2");
}
私はそれが機能するとは思っていませんでしたが、少なくとも listWidgets などが表示されることを期待していました。代わりに私はこれを得ました:
http://postimage.org/image/krrs2ijmx/
私はどこかで何か間違ったことをしていることを知っており、ここ数時間かけてその場所を見つけようとしました。お手伝いありがとう。