I am new to Qt. I took an example from here http://doc.qt.io/qt-5/qtmultimediawidgets-player-example.html. Now I want to integrate the player in the main window. I created a Qt Widgets application project, I thought, that I would just have to edit the main window code: Show
But it doesn't work and I get the following error: Starting /home/***/Documents/build-player-Desktop-Debug/player... The program has unexpectedly finished. /home/***/Documents/build-player-Desktop-Debug/player crashed How can I integrate a custom widget which is written in code, without ui in a main window? Thank you in advance. asked May 17, 2015 at 19:29
In your own
answered Oct 26, 2018 at 22:40
goulashsoupgoulashsoup 2,3782 gold badges32 silver badges57 bronze badges 1 Well, player can't be placed on the window if it is not initialized. Write something like that :
answered May 17, 2015 at 19:34
La masseLa masse 1,1601 gold badge8 silver badges24 bronze badges I usually add a QWidget (or whatever widget type I'm extending) to my .ui-file in the designer and then promote it to the actual derived type. See the Qt docs for more info on promoting widgets. This means that I can set the base widget's properties and design the window as usual but still get an instance of my special class when the UI is instantiated. answered May 17, 2015 at 20:13
user408952user408952 8629 silver badges22 bronze badges
answered Dec 9, 2019 at 20:51
Not the answer you're looking for? Browse other questions tagged c++ qt qwidget qmainwindow or ask your own question.I think I've created a circular dependency in my code, but I'm not sure if it really is circular dependency, and if it's even the correct way to do things. I know that it is possible to design a UI that can be instantiated in another UI. For example, a widget with a button that dynamically adds new buttons to the widget when pressed. I've struggled to replicate this in source/ manually until today. But the way I've designed it confuses me somewhat because it seems like two widgets depend upon each other circularly. The following are the steps that lead to the circular dependency I'm referring to:
mainwindow.h
mainwindow.cpp
customcomboclass.h
customcomboclass.cpp
Main.cpp
How do I add a custom widget to Qt?Adding the Custom Widget to Qt Designer. Click Tools|Custom|Edit Custom Widgets to invoke the Edit Custom Widgets dialog. Click New Widget so that we are ready to add our new widget. Change the Class name from 'MyCustomWidget' to 'Vcr'.
What is the main window in Qt?A main window provides a framework for building an application's user interface. Qt has QMainWindow and its related classes for main window management. QMainWindow has its own layout to which you can add QToolBars, QDockWidgets, a QMenuBar, and a QStatusBar.
|