Results 1 to 2 of 2

Thread: Help! Trying to create a ui form and use it

  1. #1
    Join Date
    Sep 2007
    Posts
    20
    Thanks
    2
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Question Help! Trying to create a ui form and use it

    Hi

    I am using Qt-Win.4.3.1 Windows Vista Microsoft Visual Studio 2005

    I created a ui form called finddlg and a class to go with it, when I try to access anything it cause a exception .

    class QCheckBox;
    class QGroupBox;
    class QRadioButton;
    class QPushButton;
    class QComboBox;

    class CFindDlg : public QWidget
    {
    Q_OBJECT
    public:
    CFindDlg(QWidget *parent);
    private slots:
    private:
    QCheckBox *ui_cbCase;
    QCheckBox *ui_cbRegex;
    QCheckBox *ui_cbTrans;
    QCheckBox *ui_cbWord;
    QCheckBox *ui_cbWrap;
    QGroupBox *ui_gbDir;
    QRadioButton *ui_rbDown;
    QRadioButton *ui_rbUp;
    QPushButton *ui_pBCancel;
    QPushButton *ui_pBFindNext;
    QPushButton *ui_pBMarkAll;
    QComboBox *ui_findcmbo;
    };

    CFindDlg::CFindDlg(QWidget *parent)
    : QWidget(parent)
    {

    int width = 488;
    int height = 162;

    QUiLoader loader;
    QFile file(":/forms/finddlg.ui");
    file.open(QFile::ReadOnly);
    QWidget *myWidget = loader.load(&file, this);
    file.close();

    ui_cbCase = qFindChild<QCheckBox*>(this,"cbCase");
    ui_cbRegex = qFindChild<QCheckBox*>(this,"cbRegex");
    ui_cbTrans= qFindChild<QCheckBox*>(this,"cbTrans");
    ui_cbWord= qFindChild<QCheckBox*>(this,"cbWord");
    ui_cbWrap = qFindChild<QCheckBox*>(this,"cbWrap");
    ui_gbDir = qFindChild<QGroupBox*>(this,"gbDir");
    ui_rbDown = qFindChild<QRadioButton*>(this,"rbDown");
    ui_rbUp = qFindChild<QRadioButton*>(this,"rbUp");
    ui_pBCancel = qFindChild<QPushButton*>(this,"pBCancel");
    ui_pBFindNext= qFindChild<QPushButton*>(this,"pBFindNext");
    ui_pBMarkAll = qFindChild<QPushButton*>(this,"pBMarkAll");
    ui_findcmbo = qFindChild<QComboBox*>(this,"findcmbo");
    QMetaObject::connectSlotsByName(this);

    QVBoxLayout *layout = new QVBoxLayout;
    layout->addWidget(myWidget);
    setLayout(layout);
    myWidget->setBaseSize(width,height);
    myWidget->setFixedSize(width,height);
    myWidget->setFixedHeight(height);
    myWidget->setFixedWidth(width);
    myWidget->show();
    myWidget->setFocus();
    ui_rbDown->setChecked(true); <---- this bombs out to a declaration of the base class item declared as private
    }

    so my question in a nutshell is , how do I access these parts of the ui properly.

    thanks for your time.
    pmabie.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Help! Trying to create a ui form and use it

    A quick question - why are you doing it in such a weird way? Why not compile the .ui usinc uic and do all the other regular stuff with it? The ui file is compiled into the binary anyway so there is no advantage in using the ui loader.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.