Skip to content
  • 0 Votes
    2 Posts
    3k Views
    C
    From the Qt documentation (qt6), QTabWidget::setCornerWidget: says: Note: Corner widgets are designed for North and South tab positions; other orientations are known to not work properly. That means they do work, but are messy to and inconvenient to use. Here's a way to use QTabWidget corner widget on the side: As already noted in the question, setting a corner widget while tabs position is West or East, causes a small gap before the tabs without anything appearing there. But if you set QTabWidget's corner widget minimum size, it will appear, which solves a problem but causes another, because now I need to calculate that size myself, or make room for my corner widget. Here's an MRE that I used to try and figure how to get that empty corner size: QTabWidget *t = new QTabWidget(); //I needed the stacked widget so I can use its geometry to calculate the empty corner size QStackedWidget *stack_widget = t->findChild<QStackedWidget*>("qt_tabwidget_stackedwidget"); t->setMinimumSize(800,600); t->addTab(new QWidget(),"Tab1"); t->addTab(new QWidget(),"Tab2"); t->addTab(new QWidget(),"Tab3"); t->addTab(new QWidget(),"Tab4"); t->setTabPosition(QTabWidget::TabPosition::West); QToolButton *button1 = new QToolButton(); button1->setIcon(QIcon(":/icons/collapse.png")); t->setCornerWidget(button1,Qt::TopLeftCorner); t->show(); //width is equal to where the stack widget starts (x coordinate) //height is equal to where the tab bar starts (y coordinate) //I subtracted 1 from stackwidget's x because it simply looked better t->cornerWidget(Qt::TopLeftCorner)->setMinimumSize(stack_widget->geometry().x()-1, t->tabBar()->geometry().y()); //checking related widgets geometries /*qDebug()<<"cornerWidget geo"<<t->cornerWidget(Qt::TopLeftCorner)->geometry(); qDebug()<<"tabBar rect"<<t->tabBar()->tabRect(0); qDebug()<<"tabBar geo"<<t->tabBar()->geometry(); qDebug()<<"stackwidget geo"<<sw->geometry();*/ Here's how it looks, I used a custom icon: [image: u2kMS.png] If you need more space for the corner widget, you'll need to move the tab bar, because corner widget will cover it, you can do that using stylesheet. See this: Qt Style Sheets Examples: Customizing QTabWidget and QTabBar. Here's an example of stylesheet: t->setStyleSheet("QTabWidget::tab-bar " "{" "top: 50px;" /* push down by 50px */ "}"); Here's how it looks with that being the only addition and change to my MRE: [image: GYKGX.png] Suggestion: QTabWidget::paintEvent might be a better solution.
  • 0 Votes
    2 Posts
    462 Views
    JonBJ
    @misscoffee So just set the size of the view and/or scene to the full size of the screen/desktop. You can also use void QWidget::showFullScreen() (see the warnings there). Be aware that widgets/windows have borders, and a title bar unless you specify otherwise, so the view/scene may not occupy every pixel of the screen, unless you take action, if that matters to you. IIRC, graphics scene/view places coordinate (0,0) in the center with x,y increasing right/up. You can use setSceneRect() to alter this.
  • Hosting MSFT WebView2 browser control in a QT QWidget

    Unsolved General and Desktop qwidget qt6 native
    1
    1 Votes
    1 Posts
    646 Views
    No one has replied
  • 0 Votes
    4 Posts
    769 Views
    D
    Hey @mrjj Digging out this topic... as I figure better to stick it in the same tree... Anyway, any idea how to make QScrollArea behave correctly too? Making it container does not let me drag widgets on it :/
  • 0 Votes
    6 Posts
    2k Views
    JoeCFDJ
    @Saviz #include <QApplication> #include <QMouseEvent> #include <QVideoWidget> class HoverVideoWidget : public QVideoWidget { public: HoverVideoWidget(QWidget *parent = nullptr) : QVideoWidget(parent) { setMouseTracking(true); // Enable mouse tracking to get hover events } protected: void enterEvent(QEvent *event) override { // Called when the mouse enters the widget setStyleSheet("background-color: lightblue;"); // Set the background color to light blue } void leaveEvent(QEvent *event) override { // Called when the mouse leaves the widget setStyleSheet(""); // Reset the background color to default } }; int main(int argc, char *argv[]) { QApplication app(argc, argv); HoverVideoWidget player; player.show(); return app.exec(); }
  • 1 Votes
    3 Posts
    2k Views
    B
    @schrute What I found to be effective, is to leave it as a bordered window, and just intercept the WM_NCCALCSIZE message, so that it does nothing. This basically gives you a bordered window, where you stop windows from drawing the borders. This way, when you implement your own title bar, aero snap will still work.
  • QWidget size in designer form is not respected.

    Unsolved General and Desktop qtablewidget qwidget
    2
    0 Votes
    2 Posts
    505 Views
    Christian EhrlicherC
    According your first picture you're missing a layout on the widget.
  • 0 Votes
    4 Posts
    811 Views
    F
    @SGaist looking at the QCamera example gave me a lot of info to fix my issue. I was using the QCamera wrongly. Too many start/stop followed by lock/unlock etc. Now the image is captured correctly.
  • How to include freeglut in a QWidget?

    Unsolved General and Desktop qwidget freeglut opengl
    1
    0 Votes
    1 Posts
    426 Views
    No one has replied
  • How to style widgets inside a scrollArea?

    Unsolved General and Desktop qscrollarea qwidget
    8
    0 Votes
    8 Posts
    2k Views
    SGaistS
    Check the generated code to see what it does differently than yours.
  • 1 Votes
    7 Posts
    3k Views
    Chris KawaC
    Since applications using burger menus usually have a very distinctive style I didn't want to make any assumptions. The look of the menu is up to you to style, it only implements the functionality. Same goes for the burger icon, you can set it to whatever you want, either the one included in the project or your own. There's an example in the repo showing how to style it. As for actions - you can add an existing QAction or let the widget create one for you using any of the overloads of addMenuAction. In any case it returns a QAction* and you can connect to its triggered signal just as you would with any other action in the built-in Qt menus. Alternatively you can tag these actions in any way you want and only make a single connection to the BurgerMenu::triggered signal. You will get an action that was triggered as a parameter. One way to tag an action is by using QAction::setData or you can just store the action pointers somewhere when creating them and identify the action by the pointer, text, some property or whatever fits you. on_actionName_triggered() looks like a slot name created for the the auto-connection feature. If you want to use it you can do that too (although I wouldn't reccomend it). Just create your actions in the designer via its action editor and make your slots names match, just like you would with any normal menus/actions. The only caveat is that you need to manually add these actions to the menu from code, as there's no way to do that in the designer, but that's not a huge problem. So those are a couple of the most straightforward options out of couple more. It's deliberately left very flexible so you can use it however fits your overall application design best.
  • 1 Votes
    8 Posts
    2k Views
    G
    I have picked up QML about three weeks ago and I am liking it very much; I have been implementing some small program with PySide6 and QML and it is a pleasure to program in it, but I do find that I can't find examples; currently, I can't get a TableView to work with the ability to edit values....where can I get some assistance?
  • Styling all of QtreeView...

    Unsolved General and Desktop qstyle qproxystyle qstylesheet qtreeview qwidget
    3
    0 Votes
    3 Posts
    1k Views
    D
    @VRonin I want to do some heavy changes/customisations... stuff I cant do in CSS... Like moving expand button to opposite of tree, changing location of checkbox, changing indentation of child items. How can I control indentation of child items? I need it now :/ I keep getting "invisible" hitboxes as my child item is moved to left visually but hitboxes are drawn in original places :/// Ideas? I just realized there is "setIndentation"... sigh............ Ok that kinda works, how can I set indentation per row? :D
  • 0 Votes
    4 Posts
    2k Views
    EmrecpE
    @VRonin Yeah you are right. Usually my custom widget has another widgets (like another label for text, button for submit etc.) so I used setItemWidget. But your way better for only images.
  • QOpenGLWindow Stacking Order

    Unsolved General and Desktop qopenglwindowqw qwidget qopengl qopenglwidget
    1
    1 Votes
    1 Posts
    568 Views
    No one has replied
  • 0 Votes
    3 Posts
    3k Views
    R
    @Chris-Kawa That would work for multiple QOpenGLWidgets in the same application. My use case involves sharing the context of one QOpenGLWidget with that of a QOffscreenSurface
  • 0 Votes
    1 Posts
    520 Views
    No one has replied
  • Widgets with SizePolicy there is no effects

    Unsolved General and Desktop pyqt5 qsizepolicy qwidget
    5
    0 Votes
    5 Posts
    2k Views
    C
    @Pythonic-person said in Widgets with SizePolicy there is no effects: Do you mean taking the main window size and then change the widget size with the code? You either use one of the provided layout mechanisms, develop you your only layout implementation, or you do all the resizing of contained widgets yourself 1990's style. If you wish to do it yourself then you need to override the resizeEvent() of the container widget and resize the contained widgets yourself using whatever logic you see fit.
  • 0 Votes
    3 Posts
    911 Views
    BDC_PatrickB
    @JonB Thanks.. found out, that i needed to create a new Pointer in the Declaration of the .h File.. Means.. TGS_Widget_AssetList * _assetList; Wasn´t enough... I needed to do: TGS_Widget_AssetList *_assetList = new TGS_Widget_AssetList(this); or auto *_assetList = new TGS_Widget_AssetList(this); Now it works.. i will update my initial post here