Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt Creator and other tools
  4. QT Designer - using .ui file tutorial bug?
Qt 6.11 is out! See what's new in the release blog

QT Designer - using .ui file tutorial bug?

Scheduled Pinned Locked Moved Qt Creator and other tools
3 Posts 2 Posters 1.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    tomypson
    wrote on last edited by
    #1

    section - The Direct Approach

    Ui::CalculatorForm ui; // this not works (calculatorform not memember of UI namespace)
    ui.setupUi(widget);

    QWidget *w = new QWidget;
    Ui::Form ui; // intelisense give me Form and this works fine
    ui.setupUi(w);

    Some wrong setting in creator settings or obsolete docu?
    for Qt newbie (like me ) its little bit frustrating.
    thanks for answers

    1 Reply Last reply
    0
    • C Offline
      C Offline
      compor
      wrote on last edited by
      #2

      are you referring to this "example":http://qt-project.org/doc/qt-4.8/designer-using-a-ui-file.html#the-direct-approach ?
      if so, did you add

      @
      #include "ui_calculatorform.h"
      @

      at the top?

      even with that though, i was not able to make it work properly.
      providing a QWidget only allows a root widget element to be there so that the rest of the widgets can use it as parent and draw themselves.

      there is no way to provide functionality with user provided slots.
      what i did was to have my main.cpp as

      @
      #include <QApplication>
      #include "calculatorform.h"

      int main(int argc, char *argv[])
      {
      QApplication app(argc, argv);

       CalculatorForm *widget = new CalculatorForm;
       widget->show();
      
       return app.exec();
      

      }
      @

      and in calculatorform.cpp

      @
      #include <QtGui>
      #include "calculatorform.h"
      #include "ui_calculatorform.h"

      CalculatorForm::CalculatorForm(QWidget *parent)
      : QWidget(parent),
      ui(new Ui::CalculatorForm)
      {
      ui->setupUi(this);
      }

      CalculatorForm::~CalculatorForm(void) {
      delete ui;
      }

      ...
      @

      purposes as understood by the purposer will be misunderstood by others

      1 Reply Last reply
      0
      • T Offline
        T Offline
        tomypson
        wrote on last edited by
        #3

        thanks for answer.
        yes i refered that example.

        i found what was wrong. In Qt Designer the widgets property objectName has default value "Form". After change to "CalculatorForm" is all ok.
        exactly like in the example.

        regards

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved