Unsolved Combining widgets
-
Can you tell me how to do this? Give some kind of example, pls
-
@TETTRA
There is no premade , just to use solution. ( that i have seen)
The code @VRonin provide is a good starting point.You should read about QDockWidget and how it works. Then
try to make it.http://doc.qt.io/qt-5/qdockwidget.html
this one also cover it.
http://www.informit.com/articles/article.aspx?p=1405543&seqNum=5If you are brand new to Qt, it's not a good start project as such as it will take
some fiddling to feel like photoshop. -
-
- I want to make a QDockWidget. Is it possible?
You mean you want to include the widgets from other files?
Ys, just include the .h from the other widgets into the Dock one and
then you can create those from code. ( and insert into Dock) -
@mrjj Sorry, but I'm new, could you give me an example?
-
@TETTRA
Example on ? -
@mrjj Yes
-
@TETTRA
sorry ?
you just include the .h file and then u can use the class//somefile.cpp
#include "mywidget.h"
then you can do
mywidget * w= new mywidget(); -
@mrjj It doesn't work out for me.
DockWidget:
#include "dockwodgets.h" #include "stylehelper.h" dockWodgets::dockWodgets() { layer = new QDockWidget(); }
Connect:
//docks docks = new dockWodgets();
-
@TETTRA
you must give more details.
what is error ?
what does not work ?
I cant tell anything from that code :)
seems fine. -
@mrjj
DockWidget#include "dockwodgets.h" #include "stylehelper.h" dockWodgets::dockWodgets() { layer = new QDockWidget(); }
MainWindow
//docks docks = new dockWodgets();
That's all I did. My program is running, but the "docks" isn,t shown.
-
@TETTRA
make sure to show() on it.
layer = new QDockWidget();
layer->show(); -
@mrjj This widget simply opens. I need him open already and attached to the main window.
-
@TETTRA
You also need to add it to the mainwindow with
http://doc.qt.io/qt-5/qmainwindow.html#addDockWidget -
@mrjj like this?
void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockWidget, Qt::Orientation orientation){ dockWidgets *docks = new dockWidgets(); docks->show(); }
-
@TETTRA
no ?
The function already exists.
so you just need to call it. not define a new function.QDockWidget * mine== new QDockWidget;
addDockWidget(Qt::LeftDockWidgetArea, mine); // this is build in function.Maybe you should try the dock sample first
http://doc.qt.io/qt-5/qtwidgets-mainwindows-dockwidgets-example.html -
@mrjj I wrote,
dockWidgets *dock = new dockWidgets; addDockWidget(Qt::LeftDockWidgetArea, dock);
but I didn't get anything done
-
Cant explain.
Try the sample first to get friends with Docks.
also
is dockWidgets
a QDockWidget?
the (s) is confusing. -
@mrjj said in Combining widgets:
Try the sample first to get friends with Docks.
also
is dockWidgets
a QDockWidget?
the (s) is confusing.So I have it in another (. Cpp) file!
-
@TETTRA
well as long as the class inherited QDockWidget it should be fine.