Skip to content
  • 0 Votes
    11 Posts
    711 Views
    S

    @Pl45m4 I tried another thing now. Just using the group as way of organizing but setting a qgraphicsrectitem as parent of the qgraphicsitem group. On mouse release i position the qgraphicsrectitem above the groupitem:

    if(DragSelectionInProgress == true){ qDebug() << "SelectionInProgress" << GroupSelectionRect; //Erstelle eine Liste aller selecteten items die nicht das grouprect sind und füge alle items dieser Liste dem grouprect hinzu if(GroupSelectionRect){ QList<QGraphicsItem *> selectedItems = this->selectedItems(); QList<QGraphicsItem *> itemsToAdd; foreach(QGraphicsItem *item, selectedItems) { if(item != GroupSelectionRect && item != SelectionRectPixItem) { itemsToAdd.append(item); } } if(itemsToAdd.count() > 1){ foreach(QGraphicsItem *item, itemsToAdd) { // Check if the item is a pixmap item or a rect item ResizablePixmapItem *rectItem = qgraphicsitem_cast<ResizablePixmapItem *>(item); if(rectItem){ rectItem->setShouldDrawHandles(false); rectItem->drawHandlesIfNecessary(false); //rectItem->setParentItem(SelectionRectPixItem); } GroupSelectionRect->addToGroup(item); } GroupSelectionRect->setParentItem(SelectionRectPixItem); SelectionRectPixItem->setRect(GroupSelectionRect->boundingRect()); //GroupSelectionRect->setSelected(true); } } DragSelectionInProgress = false; }else{ } QGraphicsScene::mouseReleaseEvent(event); }

    I can calculate exactly how many pixel the qgraphicsrectitem is resized, but how do i apply this to the group? I want the graphicsitemgroup to mimic the proportions of the qgraphicsrectitem. It should only resize, but stay anchored in the corner that is not moved.

    The green outline below is the groupitem, the handles are from the qgraphicsrectitem laying above: f41f87da-3b8b-4e26-aee5-dcf1bf1d3da3-image.png cb6797e3-0bd4-4e9e-9f11-90d6cc8547e8-image.png

  • 0 Votes
    4 Posts
    1k Views
    Chris KawaC

    Apparently separator will always fill the height of the toolbar (or width for vertical toolbars). You can limit it by adding top/bottom margins, so if your toolbar is 40px and you want the separator to be 30px add 5px top and bottom margins.

  • 0 Votes
    3 Posts
    510 Views
    D

    I have the same problem, looking for someone to answer it.

  • 0 Votes
    1 Posts
    326 Views
    No one has replied
  • 0 Votes
    5 Posts
    619 Views
    B

    I see. Thank you.

  • 0 Votes
    3 Posts
    864 Views
    CJhaC

    @Christian-Ehrlicher Ok. I understand, I will add my check boxes in a different function and not during showEvent().

    I tried setting layoutSizeConstraint to different values for the vertical layout, the QScrollArea as well as for the widget itself, because of QScrollArea my widget is always resized to a small size when shown for the first time, this is why I tried to add and resize the widget during showEvent() myself. According to Qt's documentation:

    If a scroll area is used to display the contents of a widget that contains child widgets arranged in a layout, it is important to realize that the size policy of the layout will also determine the size of the widget. This is especially useful to know if you intend to dynamically change the contents of the layout. In such cases, setting the layout's size constraint property to one which provides constraints on the minimum and/or maximum size of the layout (e.g., QLayout::SetMinAndMaxSize) will cause the size of the scroll area to be updated whenever the contents of the layout changes.

    But this is not working for me, I am setting the size constraint to QLayout::SetMinAndMaxSize but the QScrollArea remains at the minimum size when shown for the first time.

  • 0 Votes
    1 Posts
    500 Views
    No one has replied
  • 0 Votes
    1 Posts
    465 Views
    No one has replied
  • 0 Votes
    3 Posts
    618 Views
    K

    SetMinimumSize() does not work for me. I think it is because I change the window's position. However, the problem was in my form file. For an unknown reason, it changed the window's size to 802x600 when I was checking for 800x600. Maybe there was some another way out, but now all works just fine.

  • 0 Votes
    4 Posts
    961 Views
    T

    Calling the base class implementation did the trick. Thank you again!
    I didn't try the resizeToContents as some cells shouldn't be sized to their content in some context.

  • 0 Votes
    3 Posts
    2k Views
    S

    @SGaist That's a fair question and to answer that it's because on the actual dock widget itself, in the production code, there are two widgets that get placed inside the dock widget itself. The topFrame contains the layout for the QTabWidget as you have pointed out. The code that is not present, botFrame contains another QGridLayout. These two then get placed inside the QGridLayout which is the layout of QGroupBox.

    Then to answer Why am I subclassing a layout to put widgets in it? I guess this is a personal decision and can be argued either way. For now, I will say that you are correct, that the Widget should manage the way the GridLayout adds widgets to them. However, I will argue that since QGridLayout is it's own class; the Widget does not "own" the widgets, rather, the layout owns the widgets since QWidget does not have a addWidgets function in it. Therefore, QGridLayout owns and is responsible for the Widgets that it owns. Hence the decision that the QWidget is the parent, which has a QGridLayout, which the QGridLayout as the Child, has the widgets that belong inside of it.

    This is a programming decision that I made with these arguments.

  • 0 Votes
    7 Posts
    3k Views
    jsulmJ

    @YouDoItWrong said in Random crash on window resize.:

    By "bugreport" you mean code and error in this "head topic forum post"?

    No, bug report in Qt bug tracker: https://bugreports.qt.io/secure/Dashboard.jspa

  • 0 Votes
    14 Posts
    3k Views
    K

    We found a solution to that bug. The Cocoa window itself isn't set to non resizeable.
    If you do this, everything works as expected.

    class MainWindow : public QMainWindow { public: explicit MainWindow(QWidget *parent = nullptr) : QMainWindow(parent) { //this will get rid of the size grip widget showing setFixedSize(500, 500); } void mousePressEvent(QMouseEvent *) override { std::cout<<"mouse pressed"<<std::endl; } }; int main(int argc, char *argv[]) { QApplication a(argc, argv); MainWindow w; NSWindow* window = [(NSView*)w.window()->winId() window]; //IMTPORTANT. Otherwise the lower right mouse events will not be passed on correctly by cocoa window.styleMask &= ~NSWindowStyleMaskResizable; w.show(); return a.exec(); }
  • 0 Votes
    9 Posts
    4k Views
    J.HilkJ

    @AloyseTech IIRC hidePop() will reset the Popupwidget, so maybe hijack the add/remove process.
    Call hidePopup before adding are removing item and call showPopup afterwards?

  • Resizing makes slow on mac

    Unsolved General and Desktop
    2
    0 Votes
    2 Posts
    646 Views
    SGaistS

    Hi and welcome to devnet,

    What version of macOS ?

    Did you also check whether the latest beta of 5.12 has the same problem ?

  • 0 Votes
    10 Posts
    4k Views
    K

    @jsulm
    I got this, thanks

  • 0 Votes
    3 Posts
    957 Views
    GrecKoG

    Use https://doc.qt.io/qt-6/qwindow.html#startSystemResize instead. You can call it from QML.

  • 0 Votes
    1 Posts
    1k Views
    No one has replied