我正在尝试将QgraphicsView(QColorDialog)
小部件添加到Palette
对话框中,但与小部件QGraphicsScene
对应的QColorDialog
始终为空白,如果读者能帮助我纠正我的错误,那将有很大帮助。
Qt-4.8.4-Linux(CentOS)
将
GraphicsView
包含在PalletteDialog
ClrWidget::ClrWidget(QWidget *parent) : QGraphicsView(parent) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setFrameStyle(QFrame::NoFrame); setScene(new QGraphicsScene(this)); _dialog = new QColorDialog(); _dialog->setOption(QColorDialog::NoButtons, true); setMinimumSize(_dialog->size()); setMaximumSize(_dialog->size()); QGraphicsProxyWidget *proxyWidget = new QGraphicsProxyWidget(); proxyWidget->setWidget(_dialog); //scene()->addItem(proxyWidget); //scene()->setSceneRect(proxyWidget->geometry()); scene()->addWidget(_dialog); scene()->setSceneRect(_dialog->geometry()); }
PaletteDialog
构造函数PaletteDialog::PaletteDialog(QWidget *parent) : QDialog(parent), ui(new Ui::PaletteDialog), { //PaletteDialog sets up the ClrWidget ui->setupUi(this); ... }