3
我創建了一個類,它是用於繪製圖像的QWidget的子類,僅用於繪製名爲ImageWidget的圖像。Qt Widget不顯示
當我只創建ImageWidget並調用ImageWidget.show()時,一切都很好。然後我創建另一個QWidget子類,如下所示。目前,只顯示combox和滑塊,圖像不顯示。有人能幫我解決嗎?
MainWindow::MainWindow(QWidget *parent) :
QWidget(parent)
{
imgWidget=new ImageWidget(this);
fractalTypeLabel=new QLabel(tr("Type"));
typeCombo=new QComboBox();
typeCombo->addItem(tr("One"));
typeCombo->addItem(tr("Two"));
scalefactorLabel=new QLabel(tr("Scale Factor"));
scalefactorSlider=new QSlider(Qt::Horizontal);
scalefactorSlider->setTickInterval(1);
scalefactorSlider->setTickPosition(QSlider::TicksBelow);
QVBoxLayout *imageLayout=new QVBoxLayout();
imageLayout->addWidget(imgWidget);
QGridLayout *gridLayout=new QGridLayout;
gridLayout->addWidget(fractalTypeLabel,0,0);
gridLayout->addWidget(typeCombo,0,1);
gridLayout->addWidget(scalefactorLabel,1,0);
gridLayout->addWidget(scalefactorSlider,1,1);
QHBoxLayout *mainLayout=new QHBoxLayout;
mainLayout->addLayout(imageLayout);
mainLayout->addLayout(gridLayout);
this->setLayout(mainLayout);
}
最好的問候,