Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How can I edit a .ui.h file?
Forum Updated to NodeBB v4.3 + New Features

How can I edit a .ui.h file?

Scheduled Pinned Locked Moved General and Desktop
6 Posts 3 Posters 3.9k 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.
  • M Offline
    M Offline
    mango1
    wrote on last edited by
    #1

    I'm a beginner in Qt and got a Qt project.
    There is a mainform.ui file with a mainform.ui.h
    In the top of mainform.ui.h is this text written:
    ... If you want to add, delete, or rename functions or slots, use Qt Designer to update this file...

    I can open the mainform.ui.h file but I wana write my classes in it! How and where?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      It's not working like this, like the text says you have to modify mainform.ui using Qt Designer. Have a look at designer's documentation and related examples to see what you can do

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • V Offline
        V Offline
        vittalonline
        wrote on last edited by
        #3

        .ui (XML) format are converted during build process into C++ header files by UIC (User Interface Compiler). As Qt documentation says in the UIC documentation: The UIC reads an XML format user interface definition (.ui) file as generated by Qt Designer and creates a corresponding C++ header file.

        If your form filename is myform.ui, uic generates ui_myform.h. No matter what name of your class (objectName) is.

        It's actually a C++ definition of your dialog. To modify this header file makes no sense because it is recreated during the build process and any changes are lost.

        read this link
        http://sector.ynet.sk/qt4-tutorial/my-first-qt-gui-application.html

        1 Reply Last reply
        0
        • M Offline
          M Offline
          mango1
          wrote on last edited by
          #4

          I'm all mixed up!
          I went through the top sample , wrote the myqtapp.h file and after compiling I got many compiler errors and my myqtapp.h file is empty!!
          Why we write one time .h file and next time we shall not write in it!
          There is a zip file, it's the same compiler error with it. But my problem is, what is the logic here? Why is the .h after compiling empty and how can I modify this empty file???

          1 Reply Last reply
          0
          • SGaistS Offline
            SGaistS Offline
            SGaist
            Lifetime Qt Champion
            wrote on last edited by
            #5

            What error are you getting ? On what OS ? Which Qt version ?

            I've tested the zip sample and it works.

            Interested in AI ? www.idiap.ch
            Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

            1 Reply Last reply
            0
            • M Offline
              M Offline
              mango1
              wrote on last edited by
              #6

              I found a sample in Qt documentation which works. I know the top sample is for windows . I have Ubuntu 10.04 and Qt Creator 1.3.1.
              The project is written in Qt3 and I have to update it in Qt4. I did this with qt3to4 but there are many compiler errors!
              I red in the forum here that is better to write it again in Qt4. But this is also not easy! I designed the Form, but that is all what now works!

              These are the compiler errors in the project after using command make:
              g++ -c -pipe -g -Wall -W -O2 -D_REENTRANT -DQT_NO_DEBUG -DQT_THREAD_SUPPORT -DQT_SHARED -DQT_TABLET_SUPPORT -I/usr/share/qt3/mkspecs/default -I. -I. -I/usr/include/qt3 -o main.o main.cpp
              main.cpp: In function ‘int main(int, char**)’:
              main.cpp:26: error: ‘MainForm’ was not declared in this scope
              main.cpp:26: error: expected ‘;’ before ‘w’
              main.cpp:28: error: ‘w’ was not declared in this scope
              make: *** [main.o] error 1

              this is the main.cpp:
              #include <iostream>
              using namespace std;
              #include <string.h> /* String function definitions /
              #include <unistd.h> /
              UNIX standard function definitions /
              #include <fcntl.h> /
              File control definitions /
              #include <errno.h> /
              Error number definitions /
              #include <termios.h> /
              POSIX terminal control definitions */
              #include <qnamespace.h>
              #include <qapplication.h>
              #include "mainform.h"

              int main( int argc, char ** argv )
              {
              char filename[1000];
              strcpy(filename, argv[0]);
              QApplication a( argc, argv);
              MainForm w;
              sleep(5);
              w.showFullScreen();

              a.connect( &a, SIGNAL( lastWindowClosed() ), &a, SLOT( quit() ) );
              w.FormStart(&filename[0]);
              return a.exec&#40;&#41;;
              

              }

              MainForm exists in mainform.ui.h. But the UIC cannot see it!

              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