ComServant
6th January 2015, 06:21
I have a QWidget that I'm wanting to fix to the left of the QMainWindow's QMenuBar.
My code looks like this:
this->leftCornerMenuWidget = new LeftCornerMenuWidget();
this->ui->menubar->setCornerWidget(this->leftCornerMenuWidget, Qt::TopLeftCorner);
this->rightCornerMenuWidget = new RightCornerMenuWidget();
this->ui->menubar->setCornerWidget(this->rightCornerMenuWidget, Qt::TopRightCorner);
Both corner widgets display fine, but the one on the left overlaps with the menu items. How can I fix that?
My widget is a QtDesigner 'QWidget' of fixed size and height with a single QPushButton of fixed size and height, styled with stylesheets. The button displays and reacts fine.
Here's a screenshot:
10870
I'm on Win8.1 and using Qt 5.4.0 for MinGW x64
Added after 7 minutes:
Oops, I didn't see that QtCreator was outputting an error message:
setGeometryDp: Unable to set geometry 60x20+810+495 on QWidgetWindow/'LeftCornerMenuWidgetWindow'. Resulting geometry: 124x20+810+495 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 60x20, maximum size: 60x20).
The problem was that my "QWidget" that contained the "QPushButton" was a fixed size, and the QMenuBar was trying to resize it and failed. By making it have a non-fixed size, giving it a layout, but leaving my QPushButton a fixed size, everything ends up working fine.
Added after 4 minutes:
Ugh, but even though my QPushButton (with a fixed width) displays fine, and receives hover events fine, but doesn't receive mouse clicks (except for one pixel's worth of width).
Except... this is weird... My right corner widget is a QWidget that has, among other things, a QTabBar. My left cornerwidget's QPushButton receives all hover events fine, but only properly receives mouse clicks when the QTabBar in the right corner-widget is set to a tab other than the first one. If I switch to a different tab and then switch back to the first one, it can no longer receive mouse clicks again.
Now I'm really confused. In terms of behavior, that sounds like a bad pointer... but I don't see how or where. I don't think it's a pointer issue.
Any ideas about what's wrong?
My code looks like this:
this->leftCornerMenuWidget = new LeftCornerMenuWidget();
this->ui->menubar->setCornerWidget(this->leftCornerMenuWidget, Qt::TopLeftCorner);
this->rightCornerMenuWidget = new RightCornerMenuWidget();
this->ui->menubar->setCornerWidget(this->rightCornerMenuWidget, Qt::TopRightCorner);
Both corner widgets display fine, but the one on the left overlaps with the menu items. How can I fix that?
My widget is a QtDesigner 'QWidget' of fixed size and height with a single QPushButton of fixed size and height, styled with stylesheets. The button displays and reacts fine.
Here's a screenshot:
10870
I'm on Win8.1 and using Qt 5.4.0 for MinGW x64
Added after 7 minutes:
Oops, I didn't see that QtCreator was outputting an error message:
setGeometryDp: Unable to set geometry 60x20+810+495 on QWidgetWindow/'LeftCornerMenuWidgetWindow'. Resulting geometry: 124x20+810+495 (frame: 8, 31, 8, 8, custom margin: 0, 0, 0, 0, minimum size: 60x20, maximum size: 60x20).
The problem was that my "QWidget" that contained the "QPushButton" was a fixed size, and the QMenuBar was trying to resize it and failed. By making it have a non-fixed size, giving it a layout, but leaving my QPushButton a fixed size, everything ends up working fine.
Added after 4 minutes:
Ugh, but even though my QPushButton (with a fixed width) displays fine, and receives hover events fine, but doesn't receive mouse clicks (except for one pixel's worth of width).
Except... this is weird... My right corner widget is a QWidget that has, among other things, a QTabBar. My left cornerwidget's QPushButton receives all hover events fine, but only properly receives mouse clicks when the QTabBar in the right corner-widget is set to a tab other than the first one. If I switch to a different tab and then switch back to the first one, it can no longer receive mouse clicks again.
Now I'm really confused. In terms of behavior, that sounds like a bad pointer... but I don't see how or where. I don't think it's a pointer issue.
Any ideas about what's wrong?