QUiLoader Usage.



  • I have a .ui file ... I am trying to render the same using QUiLoader... the code is as below

    @
    #include <QtUiTools>
    #include <QtGui>

    #include "mainwindow.h"

    UI_from_UI::UI_from_UI(QWidget *parent)
    : QWidget(parent)
    {
    QUiLoader loader;

    QFile file&#40;":/form/mainwindow.ui"&#41;;
    file.open(QFile::ReadOnly);
    QWidget *formWidget = loader.load(&file, this);
    file.close();
    
    
    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(formWidget);
    setLayout(layout);
    
    setWindowTitle(tr("UI_from_UI"));
    

    }@

    the main() is

    @#include <QApplication>

    #include "mainwindow.h"

    int main(int argc, char *argv[])
    {
    Q_INIT_RESOURCE(ui_from_ui);

    QApplication app(argc, argv);
    UI_from_UI ui;
    ui.show();
    return app.exec();
    

    }@

    But the UI that I have created is not being rendered...

    Somebody Help...

    Thanks..



  • Could it be a problem with the .ui format or is it the usage??... my reference is the Calculator Builder Example...



  • bq. QFile file(":/form/mainwindow.ui");

    Just hypothesis: Are you sure that path to UI is right? Did not forget prefix or alias, etc?



  • Its reading the file properly.., no issues with that :-o


Log in to reply
 

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