qt - Error in using created custom widget in designer -


i having problem on using created custom widget. have created custom widget produces .dll file. placed .dll file under bin/designer. recognized in designer. used , placed on ui. when tried build it, error occurred.

debug\moc_scribblearea.cpp(44) : warning c4273: 'staticmetaobject' : inconsistent dll linkage d:\project\qt\workspace\sample-build-desktop\debug../../oep/scribblearea.h(53) : see previous definition of 'public: static qmetaobject const scribblearea::staticmetaobject'

debug\moc_scribblearea.cpp(44) : error c2491: 'scribblearea::staticmetaobject' : definition of dllimport static data member not allowed

debug\moc_scribblearea.cpp(54) : warning c4273: 'scribblearea::metaobject' : inconsistent dll linkage d:\project\qt\workspace\sample-build-desktop\debug../../sample/scribblearea.h(53) : see previous definition of 'metaobject'

debug\moc_scribblearea.cpp(59) : warning c4273: 'scribblearea::qt_metacast' : inconsistent dll linkage d:\project\qt\workspace\sample-build-desktop\debug../../sample/scribblearea.h(53) : see previous definition of 'qt_metacast'

debug\moc_scribblearea.cpp(67) : warning c4273: 'scribblearea::qt_metacall' : inconsistent dll linkage d:\project\qt\workspace\sample-build-desktop\debug../../oep/scribblearea.h(53) : see previous definition of 'qt_metacall'

how can use created custom widget correctly? there document/reference describes how use custom widget, copying .dll bin/designer folder upto building project?

i have never created custom widget stored in .dll, therefore can't on primary question, have workaround offer:

if custom widget relatively simple (it not have complex properties explicitly require form-editor) can create placeholder of kind (e.g. superclass of widget) in container-form, able set basic properties position, geometry, size & size-policy , replace placeholder custom widget using simple code in container-form constructor.

let's have following:

a. custom widget guiinpimageview inheriting qgraphicsview: guiinpimageview::guiinpimageview(qwidget *parent):qgraphicsview(parent)

b. mainwindowbase.ui (class mainwindow) @ want put instance of guiinpimageview

this workaround solution step-by-step:

  1. put .cpp source & header file guiinpimageview directly in project (not in dll)

  2. define following private member in mainwindow class header: guiinpimageview *inpimageview;

  3. open mainwindowvase.ui in form-editor , put qgraphicsview widget @ position wanted put custom guiinpimageview widget. let's have created vertical layout named inpimageviewvertlayout containing qgraphicsview named inpimageviewph (ph = placeholder). can set -if wish- geometry, min & max size , size policy of inpimageviewph using properties exposed in form-editor of qtcreator.

  4. put following code mainwindow constructor:

// main window constructor
mainwindow::mainwindow(qwidget *parent) : qmainwindow(parent)
{

setupui(this); // setup ui  // replace inpimageviewph custom widget // (inpimageviewph place holder visualize ui in design mode) inpimageview = new guiinpimageview(centralwidget); inpimageview->setgeometry(inpimageviewph->geometry()); inpimageview->setminimumsize(inpimageviewph->minimumsize()); inpimageview->setmaximumsize(inpimageviewph->maximumsize()); inpimageview->setsizepolicy(inpimageviewph->sizepolicy()); inpimageviewvertlayout->addwidget(inpimageview); // remove , hide placeholder, keep custom view inpimageviewvertlayout->removewidget(inpimageviewph); inpimageviewph->hide();  ... 

this easiest way have found insert custom widget in form using code (without creating .dll) have graphical-preview , control position & size of widget in form-container.

hope helps...


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -