QMainWindow Titlebar Style Change - qt

I am beginner and just began learning Qt.
When I created a new project, it has mainwindow.ui, mainwindow.cpp, mainwindow.h, and main.cpp.
I want to change color of title bar of mainwindow, but i can't find title bar in design mode.
How to get this done?
Thank you.

You can do it via QWidget with SIGNALS and SLOTS.
Here example how to do it: https://evileg.com/en/post/156/

Related

Can a QToolbar be added to a QDockWidget?

I have setup my app to have various dock windows within the main window. I am also able to add a toolbar to the main window. However, I would ideally like to add the QToolBar inside one of the QDockWindow instances (or the QWidget that it houses) as the toolbar will be specific to that window.
Is this possible? I'm using a recent version of Qt, 5.10.
I think it is possible.
1.QDockWidget can set a QMainWindow by setWidget() method.
QMainWindow is made for just a mainwindow but it is not prevented from being used as a subwidget.
2.QToolBar can be attached to the main-subwindow by addToolBar() method.
3.The subwidget-mainwindow can naturally have its own QToolbar.
If you don't want to use QMainWindow as the widget of its QDockWidget,you can attach the QToolBar as a child widget of QDockWidget. But The toolbar is not movable as QMainWindow's.
I think you want to add QToolBar and use it as QMainWindow.
So I recommend that you set a QMainWindow as the widget of QDockWidget.And you attach any widget you like to the mainwindow after that.

QWebEngineView display position

I used QWebEngineView to call html, and now I've shown success. however QWebEngineView is shown in the upper left corner, I want to show QWebEngineView in the white area below. First, I don't know how to do this step.Second, I don't know what kind of Qt should be used in the white area shown.Or you can provide me with a good tutorial to solve my current problem.
This is my interface:
The bar chart is the HTML file I want to display
This is the part of my code:
pEngView = new QWebEngineView(this);
pEngView->setContextMenuPolicy(Qt::NoContextMenu);
pEngView->load(QUrl("file:///html/barx.html"));
pEngView->show();
Use Qt Designer and place a QWidget at the area you wanted. Then promote the QWidget to QWebEngineView and use the ui pointer to get pointer of the webengine widget. If you are new to Qt/QtDesigner follow the tutorials.
http://doc.qt.io/qt-5/designer-layouts.html
http://doc.qt.io/qt-5/designer-using-custom-widgets.html

QT Arbitrary View Widget

plz click here to show the image
I want to create a set of UI like this.
I don't have source code, but I knew it's done by QT.
So I guess, overall, this is QTreeView
but how is its ChildWidget done?
All the child are different,
There are QCheckBox,
There are QLabel + QLineEdit
There are QTreeView too.
So I want to know how the child widgets are created and inserted to the QTreeView?
Thank you!
http://doc.qt.io/qt-5/modelview.html
ChildWidget are created by delegate. You can read more about delegate in Qt Model/View architecture

Qt: How to create a setting window like in GTK

In Qt 4.8 I want to create a window that looks like the following.
please note that my main concern is the tab-like behaviour of left-side icon+text combination.
The question is what would you recommend me to achieve that look? A QListWidget or a customized QTabWidget?
thanks
Qt Creator - which is written in Qt - has a settings page which might just be what you want:
I would look into the source code of that at http://qt.gitorious.org/qt-creator/qt-creator/trees/master
[Edit]
Found the relevant class here:
https://github.com/qt-creator/qt-creator/tree/master/src/plugins/coreplugin/dialogs
It is the class SettingsDialog. The GUI is setup in createGUI, they are not using an UI file actually.
This class is using a QListView on the left-hand side and a QStackedLayout with several QTabWidgets inside it on the right-hand side
I'd go with a QListWidget on the left connected to a QStackedWidget on the right.
Items in a QListWidget(View) can have icons on their left, selection can be exclusive (single selection) and when clicked emit signals which can change the current widget shown in the QStackedWidget.

Creating Mouse Event for image labels in QT

I am working on an application using QT. I have a mainwindow on which i have an image label. I load an image to this imagelabel and now i want to draw over it. So, my question is- how do i create mouse events for this image label only without having to derive another class of QLabel and instantiating its object to my main window.
My project's due tomorrow and its the only thing i've got left to do. I'd really appreciate the help.
Sincerely, Aayush Shrestha.
If you do not want to create a class that inherits from QLabel to get mouse event, you need to use the installEventFilter function using the eventFilter event of one of your class.

Resources