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)

  1. the graphicsview widget included in 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()); } 
  2. palettedialog constructor

    palettedialog::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

Popular posts from this blog

jquery - How can I dynamically add a browser tab? -

keyboard - C++ GetAsyncKeyState alternative -

android - java.net.UnknownHostException(Unable to resolve host “URL”: No address associated with hostname) -