Skip to content
QtWS25 Call for Papers
  • 0 Votes
    1 Posts
    97 Views
    No one has replied
  • 0 Votes
    6 Posts
    282 Views
    NarutoblazeN

    @Pl45m4 @mpergand thanks for you time it worked perfectly for me

  • 0 Votes
    11 Posts
    620 Views
    T

    I searched this a bit more.

    First of all the behavior might be depending on OS. (Noticed some differences on Unix vs Windows)

    Secondly, I created a timer that every 2 seconds prints out qApp->focusObject(). It looks like after a QEvent::ApplicationStateChange and a QEvent::WindowDeactivate that all the widgets receive afterwards, the qApp->focusObject() is always nullptr. And after nullptr Qt selects the widget on MainWindow that was the last widget to have focus, and gives focus there.

    So I feel that subwindows are ignored somehow...

    I am leaving this open for a bit, in case someone has a good solution to track if a subwindow had focus, it should regain it after application re activation.

  • 0 Votes
    8 Posts
    483 Views
    JonBJ

    @FumbleFingers said in Find and highlight a specific row in tableview:

    It may not be everyone's favourite coding style, but it works for me.

    Umm, you assign to idx in the middle of passing a parameter, and then use it afterwards!? :)

  • 0 Votes
    1 Posts
    211 Views
    No one has replied
  • 0 Votes
    9 Posts
    1k Views
    mrjjM

    @ThePyGuy

    Hi
    Im not sure its possible as QMenu get all the events when open.

    https://forum.qt.io/topic/34557/solved-prevent-qmenu-from-being-modal

  • 0 Votes
    1 Posts
    417 Views
    No one has replied
  • 0 Votes
    1 Posts
    668 Views
    No one has replied
  • 0 Votes
    11 Posts
    2k Views
    S

    Okay, got it: Relevant code resides in QApplication and cannot be changed by subclassing QWidget. There’s no way around Qt::FocusPolicy but there is the possibility to add other attributes.

    Thanks a lot!

  • 0 Votes
    4 Posts
    961 Views
    T

    Sorry for the late reply, I actually managed to figure out how to get my intended behaviour, after calling <setFloating(true)> i needed to add <setWindowFlags(Qt::Window | Qt::FramelessWindowHint);> to make it able to take focus.

  • Manage widget focus

    Solved General and Desktop
    5
    0 Votes
    5 Posts
    820 Views
    A

    @raven-worx
    Sorry if I wasn't specific enough. I solved the problem now; all I had to do was instantiating the filter and setting up the signal-slot-connections in the mainwindow.cpp and additionally (that's what I didn't grasp at first) calling

    app.installEventFilter(win->filter);

    in the main.cpp (win being the mainwindow object).

    Thanks a lot for your help!

  • 0 Votes
    10 Posts
    2k Views
    -

    Hi,
    It seems I can go with the solution I described. I don't need the tree view to be focused, so I just removed the “focus rect” (if that is the name Qt people know ;)) by setting the focus policy of the tree to Qt.NoFocus. I draw the “cursor” then myself by giving a different backlog in QAbstractItemModel::data. That makes anyway sense since the cursor position is part of my domain model.

    Thanks for help and inspiration!
    Dan

  • 0 Votes
    2 Posts
    1k Views
    ValentinMicheletV

    Hi and welcome to devnet,

    First thing, please don't delete all that stuff in your destructors. Qt has a pattern that is based on parent widget (the parameter "this" in widget constructors) that take care of destructing all the children automatically when the parent is deleted: http://doc.qt.io/qt-5/objecttrees.html

    Now regarding your problem, only one widget can have focus at the same time. For the focus part, you can use setFocusPolicy on your widgets, giving an enum that tells more about the behavior you expect.

    For what I have experienced, playing with opacity and trying to give a modern look to a desktop software is kind of a pain. Long story short: there is no user friendly API to do so, or at least as user friendly as what QML provides. This is either because the widgets part is late compared to the QML one, or because "modern" has been associated with app, browsers, Internet, but not with desktop. Nonetheless, things might evolve in the future, since Qt developers have communicated about resuming the widgets development. This doesn't solve your problem, but could explain why you are having so much trouble trying to code an overlay that behaves with good focus policy, and using low level code such as QPalette that is always a sign you're doing something wrong, or at least not initially intended. Which could be fine, if you really know what you're doing, and you are aware that you'll have to deal with a lot of work to make your application look the same on every platform.

    EDIT:
    So I created a project with your code and here are some remarks:
    1 Do not set a layout to your main window, just set the central widget with, well

    setCentralWidget(widget)

    2 qreal is an alias for double, so instead of qreal(100)/100 just write 1.0; same for qreal(50)/100, just write 0.5 and it will be perfectly fine.

    3 No need to use "this->" you are coding in C++, not JAVA ;)

    For your problem, I think I don't really get what you are expecting. Just an overlay when the setting widget pops? If so, maybe working with a QDialog (a modal one) would be better.

  • 0 Votes
    2 Posts
    805 Views
    SGaistS

    Hi,

    I'd try with a custom QDialog and use the open method.

  • 0 Votes
    4 Posts
    1k Views
    P

    La parola magica si chiama zValue:
    nei documenti html e xsl-fo sarebbe il z-index..
    piu questo numero è alto il singolo elemento è visibile...
    muovendo in drag & drop con il tasto CTRL premuto...
    vedi in:
    https://github.com/pehohlva/fop-miniscribus/tree/master/fop_miniscribus.2.0.0
    esempio x mac e window.. cercando si trova anche un pacchetto gentoo linux... 10 anni or sono che ho scritto quel coso.. il codice è rozzo ma funziona.
    https://sourceforge.net/projects/wysiwyg-edit/

    /* filter only item a top Zindex / zValue */ bool GraphicsScene::WakeUp( const QPointF incomming ) { QList<QGraphicsItem *> listing = QGraphicsScene::items(incomming); qreal thebest = 0; /* zindex on front */ for (int o=0;o<listing.size();o++) { listing[o]->setSelected(false); listing[o]->setFlag(QGraphicsItem::ItemIsSelectable,false); thebest = qMax(listing[o]->zValue(),thebest); } /* activate item at top z-index zValue / not the down not visible!!!! */ for (int e=0;e<listing.size();e++) { if (listing[e]->zValue() == thebest) { listing[e]->setFlag(QGraphicsItem::ItemIsSelectable,true); emit SelectOn(listing[e],thebest); return true; } } return false; }
  • 0 Votes
    7 Posts
    3k Views
    EddyE

    Thanks for posting your solution.

    Happy coding.

  • 0 Votes
    4 Posts
    3k Views
    SGaistS

    The Keyboard Focus in Widgets chapter from Qt's documentation already give some hints on how to handle that.

    If you build your focus chain properly you can then use nextInFocusChain and previousInFocusChain to avoid hardcoding stuff.

  • 0 Votes
    2 Posts
    2k Views
    J

    Does anyone have any ideas with this?

  • 0 Votes
    9 Posts
    4k Views
    McLionM

    I now have an eventfilter on every of my (16) webView.
    I added some debug on the MyApp notify and in the new eventfilter.
    I can see that myApp gets every keypress (first) and the installed eventfilter on the webView's gets the keypress only if any of the webView is shown.

    I'm not sure how to proceed or how this helps in forwarding the event to a specific webView since the event is not getting to the eventfilter if a webView is not active.

    How about catching the event in MyApp notify and somehow posting it to a specific webView?

    Thanks for your help.