I'm here because of a problem which remain from a long time >< !
I use Qt to develop an interactive screen using a QMidArea for multiple windows.
I have this configuration :
A class A which inherits from QWidget
A class B which inherits from A and adds some features
Then I add B into a new SubWindow.
But the problem i have is now to detect (maybe with signals and slots) when i drag a subWindow out of the QMainwindow containing all the application.
I tried to implement drag and drop into A but it clearly doesn't work because it's not A which is dragged but the subwindow...
My real aim is to detect when my subwindow hit the left border of the mainwindow.
Anyone has an idea ?
Thanks !
Related
I'm working on a qt widget project
I make it frameless and create my own custom frame for it
for drag window I subclass QWidget and use some event to keep track of window movement
everything is OK except one thing, as you can see I have a QLabel in my widget
this label are in the way of area of top_bar widget itself (because its in it actually.), So drag won't work because its on the way...
I don't know how can I fix it and keep the label
I know this is possible because this project using the same way for keep track of QWidget, and its have a label in it too but work just fine
I want to draw a caret / arrow top or bottom of a qt window. I cannot find any document regarding to this.
How can I accomplish this task with qt5? I've searched all possible words but can't find anything.
Can this be applied to QDialog or qml needed? My first choice is QDialog since I have a webengine and other qwidgets already in a QDialog.
I'm using C++.
Here is what I mean:
Most window-managers don't support non-rectangular windows directly, which means that if you want to do something like this you'll need to fake it by making the window large enough to include both its normal content and the desired caret-shape inside the window-area, and making the window transparent at the top.
To do that, call setAttribute(Qt::WA_TranslucentBackground) and setAttribute(Qt::WA_FramelessWindowHint) on your dialog, and override paintEvent(QPaintEvent *) to paint the dialog's background only for the parts of the dialog you want to be non-transparent.
I use C++, Qt 4.8.7 for creating GUI application under Windows. I have additional main window as a tab (see an image below). A, B, C, D are dockable widgets. How can I put B widget on the top of C widget? I was able to do it via mouse, but I'd like to do it programmatically. I don't want to have tabified docks.
BTW, do I have to create a dummy zero-sized central widget? Are dockable widgets more stable in Qt 5.x? Moving docks within my mainwindow is not comfortable (I've created empty small central widget).
I'm trying to write a circuit designer software in QT on Linux. I'm using KDE 5 Plasma desktop and QTCreator as an IDE.
I tried to use QFrame paintEvent to paint on it, and it worked, but when im grabbed the window inside QFrame it moved.
I know about QGraphicsView, but i cant make a custom class and promote it based on that(it's not listed).
How can i create a custom class from a container(QFrame, QGraphicsView or anything) where i can override paint event and also it doesn't move window if i grab it?
Sorry for my poor english.
QGraphicsView inherits from QAbstractScrollArea which inherits from QFrame itself.
So you can keep the QFrame in the form, and keep it promoted to your canvas class, but simply make you canvas class inherit QGraphicsView instead.
Although, my Qt has two differences in behavior from the OP (but I don't use KDE):
Clicking on a QFrame and moving the mouse doesn't move the whole window for me. I guess this behavior for the OP could be changed by reimplementing void mousePressEvent ( QMouseEvent * event ) in the canvas class and giving it an empty code instead. (doc)
I can put QGraphicsView in my ui files, and I can right click on them to promote them to another custom-defined class.
Edit: Found the reason why the window moves on KDE!
I've been doing some test with Qt 5 using C++ and I saw a lot of potential! But I came to a big wall which I haven't been able to pass yet.
I want to make a widnow that contains other windows (MDI), and I follow some of the tutorials online but the window is created by code, and I don't know how to "link" it to an UI file that I already design.
I follow the MDI tutorial that comes with Qt Creator, it works fine, but as I said before it doesn't work with custom UIs. And I found this other one that is exactly what I want, I follow it and it doesn't work I also downloaded the source code from the example, run it and still doesn't work. It opens a window with nothing in it.
If some one has an example, a good tutorial or a book that comes with the right info, I'll appreciate it.
Thanks a lot for taking the time to read this.
You should place a QMdiArea widget on your window. It provides an area in which MDI windows are displayed. It can be done via designer.
All your subwindows should inherit QMdiSubWindow which provides a subwindow class for QMdiArea :
class MyWindow : public QMdiSubWindow
{
Q_OBJECT
public:
explicit MyWindow(QWidget *parent = 0);
~MyWindow();
};
After creating a custom subwindow you can add it to the MDI area like:
MyWindow * subWindow = new MyWindow(ui->mdiArea);
MyWindow->show();
You can also add subWindows in designer by right clicking on the MDI area and choosing :
"Add subWindow"
This will add a subwindow which is viewable in designer. You can also add arbitrary widgets to the added subwindows in designer this way.