Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QMainWindow to QWidget
Does anyone know if there is a way of converting QMainWindow class to QWidget class?
Or not, then what necessary changes will I have to make to do the same?
where do you want to change it ?
Is it a designer only element or is it the base class of one of your classes ?
It is a base class of the class named "WinMain" . Now I want to make "WinMain" as a widget instead of main window so that it can be integrated in some other project.
Simply inherit QWidget instead of QMainWindow in WinMain
I tried that thing. But the main issue is it contains menu and title items. they are causing errors. they can't be included in widget.
But if you want it to have toolbar and menus, why you then want it as a QWidget ????
Also can you explain the use case since QMainWindow is already a QWidget and can be used as a QWidget
in any/most regards, like inserting into dialogs etc.
So Why do you need this ?
A project can have many MainWindows if you like. It does not matter.
You can use it as a widget while being of type QMainWindow.
Actually I am making a paint app. The code that I have, it contains all the shape icons in the TitleBar, and i want one separate widget that contains shape icons in the left side and the second is the drawable area in the right side.
Ok so all the icon code in current MainWindow need to move to another class and
that is why you want to convert the base to plain QWidget ?
Else I would just ignore that its of type QMainWindow and rename it to
something else and just use it like any other QWidget.
Yes this time you got me right. So what is the best way of doing that?
Which of the options ?
Remove all icon and non compiling code
That is simply just to do it. Manually.
Maybe its easier to take the code you want for widget and put in new QWidget and then trow out the MainWin
Use it as QWidget ?
Just do it. Its also a Qwidget besides a QMainWin so its just to do it.
Thanks for your suggestions. I think I should make a new file for QWidget and move the code to it.
Yes I would do like that instead of
chopping the old Mainwindow up.
As its easier to find out what wrong if something breaks when you have the original MainWind to look at.
So what kind of drawing app is it ? :)
It is a schematic capture used for making schematic diagrams for circuits.
Ok that sounds exciting. And slightly big project :) good luck.
Just as a note, a friend of mine made this great library
if you need inspiration/just to check out.
Yes it seems a big project. BTW thanks alot for the help :) .