Balaji
Balaji

Reputation: 3

Adding a QMainWindow class in Visual Studio 2019

I am super new to Qt programming and Visual Studio, so this question is gonna sound super lame. But please bear with me and kindly guide me through. I am creating a login page and after validation, I take the user to the home page. When I added a new QMainWindow thorough the solution explorer, I was able to create only the '.ui' file. and not the '.h' or '.cpp' files. So I deleted the '.ui' file and created a Qt class. It turns out that I can create only a QWidgets class, but I need a toolbar and a status bar, which I can't create in the 'QWidget.ui'. Please can someone help me create a 'QMainWindow.ui' with all the '.h' and '*.cpp' files? I am adding the screenshot of my problem...

Screenshot of the add new class

Screentshot of the add new file

Upvotes: 0

Views: 536

Answers (1)

Barrnet Chou
Barrnet Chou

Reputation: 1923

There are two methods to create .h and .cpp.

1.In qt installation package->qbase->bin, there is a uic.exe to create .h and .cpp corresponding to ui. You could open cmd and cd path of bin, then enter uic XXX.ui -o XXX.h and uic XXX.ui -o XXX.cp.

  1. In VS, right-click .ui file -> compile.

If you want to create .h and .cpp at the beginning, you could use QTCreator.

Upvotes: 1

Related Questions