[Interest] Change widget type of Qt Creator Form Class

Murphy, Sean smurphy at walbro.com
Fri Apr 11 20:38:56 CEST 2014


Is there a way to easily change the base class of a Qt Designer Form Class?

I created a new custom widget using Qt Creator's "Add New...->Qt->Qt Designer Form Class" wizard.  At the time, I chose "Widget" as my form template.  So at the end of that sequence I ended up with myWidget.h, myWidget.cpp, and myWidget.ui.  I then added some code.  Then I realized that I should have had the custom widget inherit from QFrame, not QWidget.  Is there an easy way to make that switch now that code is already written?

In the .h and .cpp file, it'd be trivial to do a find & replace of QWidget -> QFrame, but I'm not seeing an easy way to change the base widget type in the designer UI using the UI controls.  I'm assuming I could hack the raw XML in the .ui file and change the line:
  <widget class="QWidget" name="myWidget">
To:
   <widget class="QFrame" name="myWidget">

But that seems like a bit of a hack, and maybe that's not even sufficient?
Sean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140411/ecc39edc/attachment.html>


More information about the Interest mailing list