Add my Custom Widgets in Qt app through VS 2008

  • created a Qt app project in VS. I opened the .ui file in Qt Designer. I added "QMeter": widget (drag n drop). added the necessary .h,.cpp, .lib, .dll files and build->successful, but while i run the output window is not showing up. Even if i add the widget in the layout through

    class TestMeter : public QWidget

    TestMeter(QWidget *parent = 0);
    QVBoxLayout *layout;
    QMeter *meter;

    Ui::TestMeter ui;

    TestMeter::TestMeter(QWidget *parent)
    : QWidget(parent)
    layout = new QVBoxLayout(this);
    meter = new QMeter(this); //<----programs crashes from here
    layout->addWidget(meter, 0 ,Qt::AlignRight);

    this problem is only with my installed widgets,Arthur Widgets[Demo] and Display Widgets[Examples]. This process is working fine with QDial, QDateTime, QLabel, QSpinBox etc...

    Edit: Please use @ tags around code sections to enable code formatting; Andre

  • I don't know why it crashes, but I spottet another erorr: Your widget TestMeter already has a layout from ui.setupUi(). You would add another toplevel layout in line 25. Do not do that!

    Regarding the crash, it's hard to say what's the cause. What does the stack trace in the debugger say?

  • Thanks for our reply. yeah, that's a fundamental mistake. But i figured out the another reason for the problem.
    I build these widgets in release mode(in the .pro file), but i was building my app in debug mode.
    So when changed it in debug mode its working fine(ie by creating an object of the Widget ), but in debug mode it can't be installed in Qt Designer!!!

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.