c++ - Widgets within a QGraphicsScene -
i'm trying add qgraphicsview(qcolordialog)
widget onto palette
dialog, qgraphicsscene
corresponding qcolordialog
widget blank , of great if readers me correct mistake.
qt-4.8.4-linux(centos)
the
graphicsview
widget included inpallettedialog
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
constructorpalettedialog::palettedialog(qwidget *parent) : qdialog(parent), ui(new ui::palettedialog), { //palettedialog sets clrwidget ui->setupui(this); ... }
try this:
setscene(new qgraphicsscene); qcolordialog *_dialog = new qcolordialog(); _dialog->setoption(qcolordialog::nobuttons, true); _dialog->show(); qgraphicsproxywidget *proxywidget = scene()->addwidget(_dialog);
and remove line:
proxywidget->setwidget(_dialog);
what did wrong set widget qgraphicsproxywidget , called qgraphicsscene::addwidget(..) same thing, , doesn't work. can add qgraphicsproxywidget scene though calling qgraphicsscene::additem().
example:
setscene(new qgraphicsscene(this)); qcolordialog *_dialog = new qcolordialog; _dialog->setoption(qcolordialog::nobuttons, true); qgraphicsproxywidget *proxywidget = new qgraphicsproxywidget; proxywidget->setwidget(_dialog); scene()->additem(proxywidget);
Comments
Post a Comment