私はQtが初めてです。現状では、ボタン付きのテーブルがありますbtn
。ボタンをクリックするsetCentralWidget(view)
と、ウィンドウが引き継がれるため、テーブルが明らかに見えなくなります。しかし、を削除するとsetCentralWidget(view)
、ボタンをクリックしても何も表示されません。
両方を同じウィンドウに表示する方法はありますか? 多分分割またはドッキング?
(私の質問に関係のないコードを削除しました)
MainWindow::MainWindow()
{
//etc
packet = new QTabWidget;
setCentralWidget(packet)
}
//other code
void MainWindow::create(const QString &a)
{
QTableWidget* table = new QTableWidget;
int tabIndex = packet->addTab(table, a);
packet->setCurrentIndex(tabIndex);
table->setRowCount(1);
table->setColumnCount(2);
table->setHorizontalHeaderLabels(QString("a;Simulator").split(";"));"));
table->setItem(0,0,new QTableWidgetItem(a));
QPushButton *btn = new QPushButton("load", this);
connect(btn, SIGNAL(clicked()), this, SLOT(sim()));
table->setCellWidget(0,1, btn);
}
void MainWindow::sim()
{
QGraphicsScene* scene = new QGraphicsScene(QRect(-10, -10, 100, 50));
QGraphicsView* view = new QGraphicsView();
scene->addText("Network");
view->setScene(scene);
view->setGeometry(QRect(10, 10, 100, 50));
setCentralWidget(view);
}