antonypro / qgoodwindow Goto Github PK
View Code? Open in Web Editor NEWQGoodWindow - border less window for Qt 5 and Qt 6
License: MIT License
QGoodWindow - border less window for Qt 5 and Qt 6
License: MIT License
Hi goodwindow,
fist of all, this is an awesome project! Like โฅ
problem:
A black frame flashes on program mainwindow showing.
platform:
Qt5.15.2 + MSVC2019_x64 + Win11/Win10
analysis:
I have not seen this before 2.4.1 commit, which solves high resolusion resizing bug. So I guess it may affect by window size resizing, I try to comment this code, and this problem SOLVED, simply do nothing at updateWindowSize()
.
Why this 3x resize method is added? Any consequence without main window resizing?
// src/qgoodwindow.cpp line 3391
void QGoodWindow::updateWindowSize()
{
QTimer::singleShot(0, this, [=]{
const int border_width = BORDERWIDTH();
m_self_generated_resize_event = true;
m_main_window->resize(1, 1);
m_main_window->resize(width() + border_width, height() + border_width);
m_main_window->resize(size());
m_self_generated_resize_event = false;
});
}
Hello Antony, nice job with this library.
I was trying to modify GoodShowCase
example and save/restore the window size and position (using the standard Qt solution to do this) but it does not work with QGoodWindow and the startup position is a bit random.
MainWindow::MainWindow()
QSettings settings(QLatin1String("QGoodWindow"), QLatin1String("MainWindow"));
restoreGeometry(settings.value(QLatin1String("geometry")).toByteArray());
restoreState(settings.value(QLatin1String("windowState")).toByteArray());
}
MainWindow::~MainWindow()
{
QSettings settings(QLatin1String("QGoodWindow"), QLatin1String("MainWindow"));
settings.setValue(QLatin1String("geometry"), saveGeometry());
settings.setValue(QLatin1String("windowState"), saveState());
}
When window on secondary monitor.
I've pushed a reproducer here: https://github.com/JulienMaille/QGoodWindow
Every time the application is restarted the width is increased by 32px and the height by 6px
I discovered that you had to reimplement restoreGeometry (!) and followed the startup, what I see is the following
When closing the app, we store following geometry in the settings
QGoodWindow::normalGeometry returned { x = 2203, y = 103, width = 626, height = 642 } QRect
When resuming the app, we read from the settings
normal_geometry { x = 2203, y = 103, width = 626, height = 642 } QRect
QGoodWindow::restoreGeometry
will call QGoodWindow::resize(626, 642)
which will increase it to (642, 650) (+16, +8)
QGoodWindow::restoreGeometry
will then call QGoodWindow::showNormal()
then setGeometry(normalGeometry())
which will call again QGoodWindow::resize(642, 650)
and again increase it to (658, 658) (+16, +8)
If we skip one of the 2 size increase (I tried both) we fix on side of the issue.
Here I believe we should compensate the size increase due to border like this
QRect ng = normalGeometry();
if( m_win_use_native_borders )
{
const int border_width = BORDERWIDTH;
ng.setWidth(ng.width() - border_width * 2);
ng.setHeight(ng.height() - border_width);
}
stream << ng;
stream << bool(windowState() & Qt::WindowMinimized);
stream << bool(windowState() & Qt::WindowMaximized);
stream << bool(windowState() & Qt::WindowFullScreen);
Out of the box on Ubuntu 16.04 (QT5.15.2), the example project crashes week using x11 following the gtk calls from
bool QGoodWindow::isSystemThemeDark()
Outputs
(process:11737): GLib-GObject-CRITICAL **: g_object_get: assertion 'G_IS_OBJECT (object)' failed
(process:11737): GLib-GObject-CRITICAL **: g_object_get: assertion 'G_IS_OBJECT (object)' failed
(process:11737): GLib-GObject-WARNING **: invalid (NULL) pointer instance
(process:11737): GLib-GObject-CRITICAL **: g_signal_connect_data: assertion 'G_TYPE_CHECK_INSTANCE (instance)' failed
On Win10, with Qt5.15.2, the use of QGW with a QSplashcreen is not possible and the application crashes.
With the GoodShowCase example
QPixmap pixmap(":/splash.png");
QSplashScreen splash(pixmap);
splash.show();
MainWindow *mw = new MainWindow();
mw->show();
splash.finish(mw);
I've built QGoodWindow as a shared library using qgoodwindow-shared-lib.pro
.
I got this as a result:
I then put that in a folder and linked to that using QMake:
unix|win32: LIBS += -L$$PWD/../deps/QGoodWindow/ -lQGoodWindow
INCLUDEPATH += $$PWD/../deps/QGoodWindow
DEPENDPATH += $$PWD/../deps/QGoodWindow
...with the folder's content looking like this:
Everything went fine, until I got this error while trying to build my application:
moc_mainwindow.obj:-1: error: LNK2019: unresolved external symbol "public: static struct QMetaObject const QGoodWindow::staticMetaObject" (?staticMetaObject@QGoodWindow@@2UQMetaObject@@B) referenced in function "public: static struct QMetaObject const * __cdecl QMetaObject::staticMetaObject<&public: static struct QMetaObject const QGoodWindow::staticMetaObject>(void)" (??$staticMetaObject@$1?staticMetaObject@QGoodWindow@@2UQMetaObject@@B@QMetaObject@@SAPEBU0@XZ)
I've tried rebuilding (my application and not the library) and other things to no avail.
Hello again. Here's another issue I've encountered while trying out the no_qgoodwindow
flag:
[...]\QGoodWindow-master\QGoodWindow\QGoodCentralWidget\src\qgoodcentralwidget.cpp:435: error: C2440: 'return': cannot convert from 'int' to 'QFlags<Qt::AlignmentFlag>'
..\..\QGoodCentralWidget\src\qgoodcentralwidget.cpp(435): error C2440: 'return': cannot convert from 'int' to 'QFlags<Qt::AlignmentFlag>'
..\..\QGoodCentralWidget\src\qgoodcentralwidget.cpp(435): note: No constructor could take the source type, or constructor overload resolution was ambiguous
Occurs here at line 435:
QGoodWindow/QGoodWindow/QGoodCentralWidget/src/qgoodcentralwidget.cpp
Lines 430 to 437 in d0a17a6
Encountered while trying to build GoodShowCase & GoodPlayground. I didn't try this out on the other examples.
Hi,
I am probably just making a rookie mistake, but I am having an issue with getting QGoodWindow's basic example in the docs to run in CLion on Windows 11 with CMake 3.27.
Using:
I compiled QGoodWindow both into static and shared library on Windows 11, and moved the QGoodWindow
parent folder containing the /include
and /lib
folders to the same directory as my .cpp and CMakeLists.txt file.
Here is my current CMakeLists.txt:
cmake_minimum_required(VERSION 3.25)
project(HSMC)
set(CMAKE_PREFIX_PATH C:\\Qt\\6.5.2\\mingw_64\\lib\\cmake)
find_package(Qt6 COMPONENTS Core Widgets Gui Network REQUIRED)
# Include ./QGoodWindow/include
include_directories(${CMAKE_SOURCE_DIR}/QGoodWindow/include)
# Add the QGoodWindow library
add_library(QGoodWindow STATIC IMPORTED) # Specify as STATIC library
set_target_properties(QGoodWindow PROPERTIES
IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/QGoodWindow/lib/libQGoodWindow.a" # Adjust the library name accordingly
INTERFACE_INCLUDE_DIRECTORIES "${CMAKE_SOURCE_DIR}/QGoodWindow/include"
)
# lib containing .a and .dll
link_directories(${CMAKE_SOURCE_DIR}/QGoodWindow/lib)
set(CMAKE_CXX_STANDARD 17)
set(SOURCES
main.cpp
../UI/resources.qrc
../headers/resources.h
)
add_executable(HSMC WIN32 ${SOURCES} HSMC.rc)
target_link_libraries(HSMC PRIVATE
Qt6::Core
Qt6::Widgets
Qt6::Gui
Qt6::Network
QGoodWindow
)
qt6_add_resources(QRC_RESOURCES ../UI/resources.qrc)
This loads perfectly fine, no issues. However, as soon as I try to run the EXE built from this, I get:
Process finished with exit code -1073741515 (0xC0000135)
I tried adding the DLL/static library location in PATH as well as the MinGW compiler location to no avail. Please bear in mind that I am not well versed in C++ nor CMake, I am simply wanting to use QGoodWindow for a beginner project (On Windows, potentially a silly idea) but tried my best with CMake configurations and building from source. Asking for guidance please!
Project Structure:
(The headers directory, UI directory and associated files are all present)
Hi
Thanks for this promising project !
Do you intend by any chance to use QGW as a library ? Is that even possible ?
Thanks
First, congratulations, it is a great work!
Only a qustion confuse me,
I built the application "GoodShowCaseQML" and then run it, when i followed steps below, there is a problem here.
Hi, antonypro
Thanks your excellent work.
QGoodWindow can't handle QDockWidget right. For example, add codes int the MainWindow like that
QDockWidget *dock = new QDockWidget(tr("DockWindow1"), this);
dock->setFeatures(QDockWidget::DockWidgetMovable);
dock->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea);
QTextEdit *text1 = new QTextEdit();
text1->setText(tr("DockWindow1"));
dock->setWidget(text1);
addDockWidget(Qt::RightDockWidgetArea, dock);
Have methods to solve it?
MainWindow::MainWindow(QWidget* parent) : QGoodWindow(parent)
{
#ifdef QGOODWINDOW
title_bar = new TitleBar(pixelRatio(), this);
frame = new QFrame(this);
qDebug() << frame->winId(); // Add this line
m_frame_style = QString("QFrame {background-color: %0; border: %1;}");
Now, the window cannot move!
VS2019+QT5.15.2 x86
Thanks for the new update! Unfortunately, for me the Window resizing performance got a little worse. Furthermore I now have these black background edges when resizing, plus the widgets in the Window "jiggle around" which was not the case in the previous version. Is there any way to revert this?
First of all, thank you so much for this fantastic template!
I've added a small menu bar to see the behavior of the template, in mainwindow.cpp
auto menuBar = new QMenuBar;
auto file = menuBar->addMenu("File");
auto newfile = new QAction("New");
file->addAction(newfile);
QVBoxLayout *layout = new QVBoxLayout(frame);
layout->setMargin(0);
layout->setSpacing(0);
layout->addWidget(title_bar);
layout->addWidget(menuBar);
I've noticed some weird behavior when clicking directly on the newly created File menu bar and then clicking outside the whole window, and then back, any Idea where the problem might be?
It's not possible to resize or move a window on Ubuntu 16.04 using X11
Is it expected ?
I've tried using setMaximizeMask()
, and it works... except that it makes my maximize button unclickable.
As you can see here, the tooltip works, but the mask is preventing mouse events.
Usual button behavior.
This is my styleWindow()
code (with some taken from GoodShowCase):
void MainWindow::styleWindow() // todo: adjust these margins a bit + set rects for maximize button (win 11)
{
setMargins(titleBarWidget->height() /*Title bar height*/,
6 + m_icon->width() + 6 /*Icon size*/,
menu_bar->width() /*Left margin*/,
captionButtonsWidget->width() + 3 /*Right margin*/);
setCaptionButtonsHandled(true, Qt::TopRightCorner);
//setRightMask(QRegion(captionButtonsWidget->rect()));
setMaximizeMask(QRegion(m_button_maximize->width() + 3, 0, m_button_maximize->width(), m_button_maximize->height()));
//qDebug() << maximizeMask();
bool maximized = isMaximized();
m_button_maximize->setVisible(!maximized);
m_button_maximize->setEnabled(!maximized);
m_button_restore->setVisible(maximized);
m_button_restore->setEnabled(maximized);
}
What am I doing wrong? (if You need more code, let me know)
While playing around with the CaptionButtons and implementing a solution with them including the QSVGWidgets, I found that there is a slight offset of the area that activates hover event as seen in the photo
This offset increases the more the scaling factor in Windows increases (maybe it is also affected by monitor size? I use 1440p but not sure about that...)
I digged in the code but so far I was unable to find, where this hover area is even coming from because to me it does not seem to be coming from within the CaptionButton class itself.
(the foto was taken at 225% scaling, I know noone should use such a large scaling factor but this issue also seems to be slightly present at 100% for me.
Note that I did change the width of the CaptionButtons to 36, but for me this issue was also present for the default width.)
Hi, wow this is a amazing project thanks for it! So while I was playing around with the examples, GoodShowCase renders the main menu with an offset when moved to second monitor.
Could be a QT bug not sure, will investigate more on my side as well.
Using QGoodWindow : 2.4.2
QT Version : 5.14.2
Windows 11
The windows app usually restore focus.
I'm trying to add always on top functionality in my application, but it seems that it isn't working. I know that the windowFlags are internally handled, but I tried to append the Qt::WindowStaysOnTop to all the initializations. It works if I remove anything related to FramelessWindow, but this beats the purpose, haha. Any ideas, or is it impossible?
Hello again!
I'm loving the 2.1 update so far and I've noticed that QGoodWindow now has built in dark and light themes. However, as far as I know, these things are hardcoded and I think passing custom themes through an API call or two would be nice.
In fact, I might be able to implement this myself and create a pull request later.
I am trying to add a dockable widget to the left of my current window using QGoodWindow
.
QGoodWindow mainWindow;
QGoodCentralWidget* gCentralWidget = new QGoodCentralWidget(&mainWindow);
QWidget* widget= new QWidget();
gCentralWidget->setCentralWidget(widget);
When I try to set a dock widget
Outliner* outliner = new Outliner();
QDockWidget* outlinerDock = new QDockWidget("Outliner");
outlinerDock->setWidget(outliner);
mainWindow.addDockWidget(Qt::LeftDockWidgetArea, outlinerDock);
I want the dockable widget to be under title bar, but the dockable widget seems to be moving the titlebar. The minimize buttons are all are also in wrong area now, I assume because of the title bar shifting.
If I add the pri in my project and all files are correctly included in QtCreator project, I still get "File not found" when I add "#include "
Seems like stupid question, but I just do not find why it is not working. :(
QGoodWindow works excellent! I have been looking for a good implementation of a Qt frameless application for a long time.
However, your functions QGoodWindow::setMargins is good for simple cases. I suggest you add a function that accepts QRegion as input. I studied your code, and as I understand it, it's pretty simple to do.
Hello, I really appreciate your work.
I have a problem about scale factor of QMenu of QSystemTrayIcon.
Whenever I change scaling of display, size of QMenu of QSystemTrayIcon is not changed.
I want to know how to fit the scale of qmenu size.
Hi there. First, this project is great, really helpful, it's been just what I needed, but I have this little annoying thing happening.
All I'm trying to do is change the window control button widths from 36 to 46, but when I do, it's like the area the titlebar detects for hovering over the control buttons doesn't change. So the minimize button at 46 width is bugged:
minbtn = new CaptionButton(CaptionButton::IconType::Minimize, pixel_ratio, this);
minbtn->setFixedSize(qRound(36 * pixel_ratio), qRound(29 * pixel_ratio));
restorebtn = new CaptionButton(CaptionButton::IconType::Restore, pixel_ratio, this);
restorebtn->setFixedSize(qRound(36 * pixel_ratio), qRound(29 * pixel_ratio));
maxbtn = new CaptionButton(CaptionButton::IconType::Maximize, pixel_ratio, this);
maxbtn->setFixedSize(qRound(36 * pixel_ratio), qRound(29 * pixel_ratio));
clsbtn = new CaptionButton(CaptionButton::IconType::Close, pixel_ratio, this);
clsbtn->setFixedSize(qRound(36 * pixel_ratio), qRound(29 * pixel_ratio));
to
minbtn = new CaptionButton(CaptionButton::IconType::Minimize, pixel_ratio, this);
minbtn->setFixedSize(qRound(46 * pixel_ratio), qRound(29 * pixel_ratio));
restorebtn = new CaptionButton(CaptionButton::IconType::Restore, pixel_ratio, this);
restorebtn->setFixedSize(qRound(46 * pixel_ratio), qRound(29 * pixel_ratio));
maxbtn = new CaptionButton(CaptionButton::IconType::Maximize, pixel_ratio, this);
maxbtn->setFixedSize(qRound(46 * pixel_ratio), qRound(29 * pixel_ratio));
clsbtn = new CaptionButton(CaptionButton::IconType::Close, pixel_ratio, this);
clsbtn->setFixedSize(qRound(46 * pixel_ratio), qRound(29 * pixel_ratio));
I've changed nothing else about the QGoodWindow source. Making a different class myself for the buttons to replicate them is easy enough, but I'm just confused and curious why this happens with your code.
Hello again. I'm back another with another issue; this time it's not really a bug, rather a request for an enhancement.
When using showMinimized();
, the window does get minimized, however it doesn't lose focus (somehow) and remains selected in the taskbar and other places:
The behavior I expected is the previous active window regaining focus.
Tested this out on GoodShowCase too.
(I'm sorry for creating so many issues... I'm trying to properly learn how to use the library and help its development as much as I can.)
(continuation of issue #16 )
Okay, so, I've managed to add a QMenuBar to the title bar and set the left margin for it.
The issue is - the left margin treats everything as an icon and I can't click on the menu bar. Notice how double clicking that area also closes the window, as if I double clicked an actual icon.
Here's an example without the small icon next to it.
A potential solution would be to have two left margins: one for the actual icon, and another to let clicks through.
Hello:smile:. First of all, this project is really helpful, but I ran into a few annoying little things.
When I try to execute the QDialog, the program crashes.
A simple example is as follows, just insert the following code here:
QPushButton* button = new QPushButton("exec QDialog", this);
button->setGeometry(50, 50, 100, 25);
connect(button, &QPushButton::clicked,
[this]()
{
QDialog* dialog = new QDialog(this);
dialog->exec();
});
QGoodWindow/QGoodWindow/Examples/ExampleMinimal/mainwindow.cpp
Lines 27 to 30 in 019f43e
When I press the button, the displayed dialog keeps flashing and zooming in, then the program crashes. Like this:
10:32:08: Starting E:\QGoodWindow\QGoodWindow\Examples\build-ExampleMinimal-Desktop_Qt_6_2_4_MSVC2019_64bit-Debug\debug\ExampleMinimal.exe...
QWindowsWindow::setGeometry: Unable to set geometry 186x1086+809-62 (frame: 202x1125+801-93) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 186x1061+809-62 (frame: 202x1100+801-93) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 202x1100+801-76 (frame: 218x1139+793-107) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 202x1061+801-76 (frame: 218x1100+793-107) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 218x1139+793-115 (frame: 234x1178+785-146) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 218x1061+793-115 (frame: 234x1100+785-146) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 234x1178+785-154 (frame: 250x1217+777-185) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 234x1061+785-154 (frame: 250x1100+777-185) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 250x1100+777-76 (frame: 266x1139+769-107) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 250x1061+777-76 (frame: 266x1100+769-107) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 266x1139+769-115 (frame: 282x1178+761-146) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 266x1061+769-115 (frame: 282x1100+761-146) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 282x1178+761-154 (frame: 298x1217+753-185) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 282x1061+761-154 (frame: 298x1100+753-185) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 298x1217+753-193 (frame: 314x1256+745-224) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 298x1061+753-193 (frame: 314x1100+745-224) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 314x1100+745-76 (frame: 330x1139+737-107) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 314x1061+745-76 (frame: 330x1100+737-107) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 330x1139+737-115 (frame: 346x1178+729-146) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 330x1061+737-115 (frame: 346x1100+729-146) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 346x1178+729-154 (frame: 362x1217+721-185) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 346x1061+729-154 (frame: 362x1100+721-185) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 362x1217+721-193 (frame: 378x1256+713-224) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 362x1061+721-193 (frame: 378x1100+713-224) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 378x1256+713-232 (frame: 394x1295+705-263) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 378x1061+713-232 (frame: 394x1100+705-263) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 394x1100+705-76 (frame: 410x1139+697-107) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 394x1061+705-76 (frame: 410x1100+697-107) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 410x1139+697-115 (frame: 426x1178+689-146) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 410x1061+697-115 (frame: 426x1100+689-146) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 426x1178+689-154 (frame: 442x1217+681-185) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 426x1061+689-154 (frame: 442x1100+681-185) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 442x1217+681-193 (frame: 458x1256+673-224) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 442x1061+681-193 (frame: 458x1100+673-224) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 458x1256+673-232 (frame: 474x1295+665-263) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 458x1061+673-232 (frame: 474x1100+665-263) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 474x1295+665-271 (frame: 490x1334+657-302) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 474x1061+665-271 (frame: 490x1100+657-302) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 490x1100+657-76 (frame: 506x1139+649-107) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 490x1061+657-76 (frame: 506x1100+649-107) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 506x1139+649-115 (frame: 522x1178+641-146) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 506x1061+649-115 (frame: 522x1100+641-146) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 522x1178+641-154 (frame: 538x1217+633-185) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 522x1061+641-154 (frame: 538x1100+633-185) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 538x1217+633-193 (frame: 554x1256+625-224) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 538x1061+633-193 (frame: 554x1100+625-224) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 554x1256+625-232 (frame: 570x1295+617-263) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 554x1061+625-232 (frame: 570x1100+617-263) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 570x1295+617-271 (frame: 586x1334+609-302) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 570x1061+617-271 (frame: 586x1100+609-302) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 586x1334+609-310 (frame: 602x1373+601-341) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 586x1061+609-310 (frame: 602x1100+601-341) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 602x1100+601-76 (frame: 618x1139+593-107) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 602x1061+601-76 (frame: 618x1100+593-107) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 618x1139+593-115 (frame: 634x1178+585-146) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 618x1061+593-115 (frame: 634x1100+585-146) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 634x1178+585-154 (frame: 650x1217+577-185) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 634x1061+585-154 (frame: 650x1100+577-185) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 650x1217+577-193 (frame: 666x1256+569-224) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 650x1061+577-193 (frame: 666x1100+569-224) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 666x1256+569-232 (frame: 682x1295+561-263) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 666x1061+569-232 (frame: 682x1100+561-263) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 682x1295+561-271 (frame: 698x1334+553-302) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 682x1061+561-271 (frame: 698x1100+553-302) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 698x1334+553-310 (frame: 714x1373+545-341) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 698x1061+553-310 (frame: 714x1100+545-341) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 714x1373+545-349 (frame: 730x1412+537-380) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 714x1061+545-349 (frame: 730x1100+537-380) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 730x1100+537-76 (frame: 746x1139+529-107) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 730x1061+537-76 (frame: 746x1100+529-107) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 746x1139+529-115 (frame: 762x1178+521-146) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 746x1061+529-115 (frame: 762x1100+521-146) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 762x1178+521-154 (frame: 778x1217+513-185) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 762x1061+521-154 (frame: 778x1100+513-185) margins: 8, 31, 8, 8)
QWindowsWindow::setGeometry: Unable to set geometry 778x1217+513-193 (frame: 794x1256+505-224) on QWidgetWindow/"QDialogClassWindow" on "24B2W1". Resulting geometry: 778x1061+513-193 (frame: 794x1100+505-224) margins: 8, 31, 8, 8)
......(Similar to above.)
Using Windows11, Visual Studio 2022, Qt 6.2.4.
Scaling 100%, QGoodWindow is present
Scaling 100%, QGoodWindow is bypassed
Scaling 125%, QGoodWindow is present
Scaling 125%, QGoodWindow is bypassed
Another thing I noticed is that the QGoodWindow shadow on Windows 10 also behaves weirdly. I might send a video demonstrating this later.
Source code for this is here (EDIT: removed the link since it was unnecessary) (run with -q
as an argument to bypass QGoodWindow).
Hello, I encountered such a problem:
This happens on the second screen.
Primary screen dpi: 125% (1080p)
Second screen dpi: 125% (4k)
QMainwindow version: Current master branch
Windows OS: Windows 10 Home, 22H2, 19045.2728
Test on
All have this problem.
I am talking about PyQt6 bindings specifically
As a test, I've tried enabling the no_qgoodwindow
flag in the ExampleMinimal, ExampleMinimalWindow and GoodShowCase examples and in both I get these linker errors from MSVC:
stylecommon.obj:-1: error: LNK2019: unresolved external symbol __imp_LoadIconW referenced in function "class QPixmap __cdecl StyleCommon::winStandardPixmap(enum QStyle::StandardPixmap)" (?winStandardPixmap@StyleCommon@@YA?AVQPixmap@@W4StandardPixmap@QStyle@@@Z)
stylecommon.obj:-1: error: LNK2019: unresolved external symbol __imp_DestroyIcon referenced in function "class QPixmap __cdecl StyleCommon::winStandardPixmap(enum QStyle::StandardPixmap)" (?winStandardPixmap@StyleCommon@@YA?AVQPixmap@@W4StandardPixmap@QStyle@@@Z)
All three examples work fine without this flag.
Using Qt 6.4.2 on Windows 10.
Hello and thank you for this well-functioning library.
There is a problem when using QFileDialog::getOpenFileName from the main window: the dialog is displayed correctly but a second window appears, with the same title...
To help you reproduce the problem, I have modified your example called 'ExempleMinimal' as follows:
MainWindow::MainWindow(QWidget *parent) : QGoodWindow(parent)
{
setMargins(40,0,0,0);
QPushButton *button = new QPushButton("&Download", this);
this->setCentralWidget(button);
connect(button,&QPushButton::clicked,this, [=]{
QFileDialog::getOpenFileName(this, tr("TEST file"), "c:\\", tr("TEST (.txt)"));
});
}
Thanks you !
crash when call QApplication::exit() to exit application in windows 10.
exception triggered in QGoodWindow::WndProc
:
example code in mainwindow.cpp:
MainWindow::MainWindow(QWidget *parent) : QGoodWindow(parent)
{
QWidget *centralWidget = new QWidget();
QHBoxLayout *layout = new QHBoxLayout(centralWidget);
QPushButton *button = new QPushButton("Button");
layout->addWidget(button);
setCentralWidget(centralWidget);
connect(button, &QPushButton::clicked, this, [](){
QApplication::quit(); // or exit();
});
}
I have graphic glitches with gnome-shell (ubuntu 22-04) whit the app in maximized mode. Do you also have this problem?
All the examples crash when they are run inside a wayland compositor, such as weston and wayfire. The crash can be triggered by moving the mouse into the titlebar area. Sometimes, moving the mouse in any part of the window causes the crash.
Edit: Trying to run the examples in Xwayland (using -platform xcb
switch) causes a black window to open along with the actual window. See screenshots below:
To use this library in a CMake project, I had to rewrite the pro/pri files into CMakeLists.txt (I used qmake2cmake by Qt to achieve this). It would be nice to have both so that this can be used in either build system.
I am using your example ExampleMinimalWindow as a base.
The issue is reproducable by using this as mainwindow.cpp:
#include "mainwindow.h"
MainWindow::MainWindow(QWidget *parent) : QGoodWindow(parent) {
m_good_central_widget = new QGoodCentralWidget(this);
//Contents of the window
QQuickWidget *bg = new QQuickWidget(this);
bg->setObjectName("backgroundWidget");
//Function that sets the state holder theme
auto func_theme = [=] {
qGoodStateHolder->setCurrentThemeDark(QGoodWindow::isSystemThemeDark());
};
//React to state holder theme change and apply our dark or light theme to the whole app
connect(qGoodStateHolder, &QGoodStateHolder::currentThemeChanged, this, [=] {
if (qGoodStateHolder->isCurrentThemeDark())
setAppDarkTheme();
else {
setAppLightTheme();
}
});
//React to system theme change
connect(this, &QGoodWindow::systemThemeChanged, this, func_theme);
//Set the central widget of QGoodCentralWidget
m_good_central_widget->setCentralWidget(bg);
//Set the central widget of QGoodWindow which is QGoodCentralWidget
setCentralWidget(m_good_central_widget);
//Set initial theme
func_theme();
}
MainWindow::~MainWindow() {
qDebug() << "Destructor is executed after the warning";
}
When closing the window, I get the following warning just before the program crashes:
QRhi 0x1f60bef8030 going down with 3 unreleased resources that own native graphics objects. This is not nice.
RenderBuffer resource 0x1f60a2339d0 ()
Texture resource 0x1f60bea3f10 ()
TextureRenderTarget resource 0x1f60c11dd60 ()
Destructor is executed after the warning
- TIME - : - MY PROJECT PATH\example.exe crashed.
So this is not catastrophic and I'll continue using the QQuickWidget because otherwise the program always works out fine. The average user may not care if the program crashes instead of closing properly (if he wanted the program to end anyway), but I thought, I report it as I didn't manage to really fix it and maybe you know what this is about.
When asking ChatGPT, it suggested to execute bg->deleteLater();
when trying to close the program, however, the warning was always thrown before an implementation of bg->deleteLater()
(for example in a closeEvent
override) was executed in the code.
Qt source code (https://code.qt.io/cgit/qt/qtbase.git/tree/src/gui/rhi/qrhi.cpp at line 7506) indicates, that the application somehow manages to destroy the resources of a QRhi after the QRhi itself. (but didn't figure out yet, what exactly that means, I'll let you know if I find out anything interesting about it).
Hello
Last week I transferred a big project with several windows os dependencies to QGoodWidnow. In the process, I ran into a couple of problems that I could not solve myself. Could you share the probable reasons behind the following points?
[&](){ wgt.show(); }()
) to fix it. No idea why but it's enough to safely call ::show. Other QGoodWindow methods cause exception but not all.> Qt5Cored.dll!QTimer::stop() Row 242 C++
cyber_frac_full.exe!Shadow::showLater() Row 86 C++
cyber_frac_full.exe!QGoodWindow::WndProc(HWND__ * hwnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Row 2985 C++
> cyber_frac_full.exe!std::_Atomic_storage<int,4>::load(const std::memory_order _Order) Row 1001 C++
cyber_frac_full.exe!QAtomicOps<int>::loadRelaxed<int>(const std::atomic<int> & _q_value) Row 240 C++
cyber_frac_full.exe!QBasicAtomicInteger<int>::loadRelaxed() Row 107 C++
cyber_frac_full.exe!QWeakPointer<QObject>::internalData() Row 701 C++
cyber_frac_full.exe!QPointer<QWidget>::data() Row 77 C++
cyber_frac_full.exe!QPointer<QWidget>::operator QWidget *() Row 83 C++
cyber_frac_full.exe!QGoodWindow::QGoodWindow(QWidget * parent, const QColor & clear_color) Row 405 C++
> Qt5Cored.dll!QScopedScopeLevelCounter::QScopedScopeLevelCounter(QThreadData * threadData) Row 323 C++
Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Row 1072 C++
Qt5Cored.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Row 1471 C++
cyber_frac_full.exe!QGoodWindow::WndProc(HWND__ * hwnd, unsigned int message, unsigned __int64 wParam, __int64 lParam) Row 2615 C++
I can't reproduce the described behavior in small projects. In the big project there is too much code to determine the reason that causes the problems above.
Is there any plan to support Qt's scaling strategy?
QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling);
QGuiApplication::setAttribute(Qt::AA_UseHighDpiPixmaps);
QGuiApplication::setHighDpiScaleFactorRoundingPolicy(Qt::HighDpiScaleFactorRoundingPolicy::PassThrough);
MainWindow::MainWindow(QWidget *parent) : QGoodWindow(parent)
{
QPushButton *btn = new QPushButton("test", this);
btn->setMaximumSize(120, 40);
connect(btn, &QPushButton::clicked, this, [this](){
QDialog log(this);
QVBoxLayout *out = new QVBoxLayout(&log);
auto *sd = new QLabel("Test", &log);
out->addWidget(sd);
log.exec();
});
setCentralWidget(btn);
}
When I click the button, the dialog automatically stretches and an error is reported.
I'm learning about this great open source library, but I don't understand what it means here.
QGoodWindow/QGoodWindow/QGoodCentralWidget/src/qgoodcentralwidget.cpp
Lines 565 to 581 in d0a17a6
This place has been judged twice
if (!widget->mask().isNull() || widget->testAttribute(Qt::WA_TransparentForMouseEvents))
and
if (!widget->mask().isNull() && !widget->testAttribute(Qt::WA_TransparentForMouseEvents))
Looking forward for your reply, thank you.
Hello. I'm back again with another issue and this time I really am not sure if this is an issue on my behalf or not.
When using a regular QMainWindow, connecting a QAction to a QDialog's open()
slot works fine. The dialog's parent is the QMainWindow and it opens in the center, even after moving.
// Example code
AboutWindow *aboutWindow = new AboutWindow(this); // inherits QDialog
connect(helpAction, &QAction::triggered, aboutWindow, &AboutWindow::show);
Position after being moved by cursor
However, if I connect that same QAction to the same show()
slot, but this time have a QGoodWindow as its parent, this happens:
Position after being moved by cursor
If I use move()
on the dialog's parent window before it being shown, that is used as the initial position instead.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.