Widget overlapping on a widget



  • hey, i have an application in which i have to expand the size of a widget but such that it is displayed over other widgets and doesn't move the them like a menu or a combobox which when opens are showed on top of other widgets and they dont change the structure . i want to implement the same with listwidget, i want to expand the list size on runtime but when expanded it should overlap the surrounding widgets


  • Moderators

    @
    listWidget->setWindowFlags( Qt::Tool ); //or Qt::ToolTip
    @

    If you want to behave it like a QMenu you can set Qt::Popup, so it gets closed automatically when it loses focus or the mouse is pressed outside of the widget.

    Play around which of the 3 flags you want to use.



  • the popup thing is not working the list that pops up renders the remaining window useless . i just want it to display the message and move back.

    what i want is actually a type of an error log that displays only the latest message normally but whenever when i place my cursor on it it displays the whole list . but it should be displayed on top of the screen and not move the rest of the widgets


  • Moderators

    something like a tool-tip then?



  • yes but position over the calling widget
    can you tell me how to pass a list as a tool tip


  • Moderators

    ok i think now i got you.

    You can use a QLabel (or any other appropriate widget you like) to display the last error message. Then on any desired action you can display the list widget over the label. To do so you can use setWindowFlags(Qt::ToolTip)



  • but how do i show the tooltip because a tooltip has a constructor of only string
    and if i use the show function it becomes a seperate window


  • Moderators

    [quote author="tanmay2227" date="1383814041"]but how do i show the tooltip because a tooltip has a constructor of only string
    [/quote]
    a QToolTip is a special widget which only accepts strings. To simulate a tool-tip with a abitrary widget use the way i said.

    [quote author="tanmay2227" date="1383814041"]
    and if i use the show function it becomes a seperate window[/quote]
    like a tool-tip...



  • can you tell me the function used to call the widget as a tooltip because the ones i have tried are not working


  • Moderators

    for the third time: QWidget::setWindowFlags(Qt::ToolTip)



  • i understood what you are trying to say i have done that
    @customerList->setWindowFlags(Qt::ToolTip);
    // QWidget::setWindowFlags(Qt::ToolTip);@

    i have tried both these things but how to show it after this

    because i need it to appear when the cursor is on a particular widget


  • Moderators

    just set the geometry and call show().
    Since you set the windowflags it becomes a top-level widget and thus has global coordinates.
    So maybe you want to do do something like this:
    @
    QPoint pos = errorMessageLabel->mapToGlobal(QPoint(0,0));
    //listView->setWindowFlags(Qt::ToolTip);
    listView->move( pos );
    listView->show();
    @



  • i did that too but that is also not working . it shows up at the top left hand corner and also it stays even when i click elsewhere on the screen and even when i close the window it doesnt disappear .
    it is like a separate entity altogether


  • Moderators

    i feel like i have to repeat myself a few times:
    [quote author="raven-worx" date="1383730620"]
    If you want to behave it like a QMenu you can set Qt::Popup, so it gets closed automatically when it loses focus or the mouse is pressed outside of the widget.

    Play around which of the 3 flags you want to use.[/quote]



  • i am sorry that you have to repeat yourself but perhaps you misunderstood me
    i have tried with both the flags i have played around with them but both of them are producing problems .

    the main problem is occuring not because of whether i am using popup or tooltip but whether i am adding the list to the layout or not.

    if i add the list to the layout and hide it and then on the event call for a show then it behaves like a normal widget and pushes the other widgets away and doesnt overlap them

    and if i do not add it , be it popup or tooltip it is not losing focus from it



  • quote author="tanmay2227" date="1383826314" but whether i am adding the list to the layout or not. (...)[/quote]

    I think that you're using a QLayout to show some widgets and when you enter one of these you want a tooltip to appear.
    If the tooltip widget (whatever type of widget you're using) is simply added to the QLayout, it would be displayed along the other widgets inside the QLayout grid - this forces the QLayout to reisze the grid to accommodate the new widget, so it moves and resizes existing widgets which is what you're desperately trying to avoid.
    Solution: use a widget from the ones added to the QLayout as a parent of the tooltip widget you're displaying.

    Now, don't get me wrong but raven has repeated himself because the question wasn't explained in its context. Next time try to explain you're using a QLayout or other widgets and even a little piece of code (even example if you don't want to share your source code) can be of help to determine your problem and solution :)



  • thank you and sorry for the misunderstanding


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.