Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QWidget editor - force stay on top?
Forum Updated to NodeBB v4.3 + New Features

QWidget editor - force stay on top?

Scheduled Pinned Locked Moved General and Desktop
10 Posts 2 Posters 3.5k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    maximus
    wrote on last edited by
    #1

    Hi,

    I have this current UI:
    https://www.dropbox.com/s/vylw64thx1cnt0c/goodUi.png

    I have a small problem, when I click a row that is in the last 3 rows in the QTableView, the widget editor that is created is hidden inside the QTableView and the user has no way of showing it completely, see problem in action :
    https://www.dropbox.com/s/ij6yonr4m7uk7ii/badUi.png

    Is there an attribute for a QWidget that force it to draw on top of everything else?
    I tried with a few on them without success
    Thanks!

    Code that trigger my QWidget (custom QStyledItemDelegate):
    @QWidget *IntervalDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const

    {
    [...]
    /// Power
    else if (index.column() == 2 ) {
    PowerEditor *editor = new PowerEditor(parent);
    return editor;
    }
    }@

    My QWidget :
    @PowerEditor::PowerEditor(QWidget *parent) :
    QWidget(parent),
    ui(new Ui::PowerEditor)
    {
    ui->setupUi(this);

    setAutoFillBackground(true);
    setAttribute(Qt::WA_NoMousePropagation);
    setWindowFlags(Qt::WindowStaysOnTopHint);  //not working..
    

    }@


    Free Indoor Cycling Software - https://maximumtrainer.com

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What OS/Qt combo are you currently using ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • M Offline
        M Offline
        maximus
        wrote on last edited by
        #3

        Hey,

        The above screenshot is on windows 8.1 latest Qt.
        I have the same behavior happening on OSX Mavericks
        See here :
        https://www.dropbox.com/s/ef2h4olztvmt9po/macOSGUI.png

        Maybe I need to force a vertical scroll bar earlier on the QTableView, when the QTable view has space for 2 more rows, that's when I need to force a vertical Scroll bar and increase QTableView Height, not clean but could work..

        Another thing, the "repeat Widget (widget with the red box)" is different on OSX, seems like there some kind of background line shown on OSX, guess i'm going to have fun making this work for both platform, for example, on OSX my columns seem too small because of the bigger font ;)

        Here is my code when I attach a "Repeat Widget" in the QTableView :
        @ RepeatWidget *repeatWidget = new RepeatWidget(ui->tableView->viewport());
        repeatWidget->id = idRepeatWidget;
        repeatWidget->firstRow = firstIndex.row();
        repeatWidget->lastRow = lastIndex.row();
        repeatWidget->numberRepeat = 2;
        repeatWidget->move(rectCompleteSelection.topLeft());
        repeatWidget->resize(rectCompleteSelection.size().width() + 190, rectCompleteSelection.size().height());
        repeatWidget->show();@

        Thank you


        Free Indoor Cycling Software - https://maximumtrainer.com

        1 Reply Last reply
        0
        • M Offline
          M Offline
          maximus
          wrote on last edited by
          #4

          I made this little image to show the behavior I would like:
          https://www.dropbox.com/s/9py1vpsovso4eoz/popUpOutsideOk.png

          I would just like to mimic the ContextMenu behavior, when it pop up, is there a specific flag that is set in order to show it on top of all widget?

          Currently, I'm using theses flags on my Widget editor so that it pop up oustide the QtableView, but it's not working

          @ setAutoFillBackground(true);
          setAttribute(Qt::WA_NoMousePropagation);
          setWindowFlags(Qt::WindowStaysOnTopHint);@

          Thanks


          Free Indoor Cycling Software - https://maximumtrainer.com

          1 Reply Last reply
          0
          • M Offline
            M Offline
            maximus
            wrote on last edited by
            #5

            I tried changing the editor parent to something else, but the same problem still happen.... editor is not top-level.. grr

            @QWidget *IntervalDelegate::createEditor(QWidget *parent, const QStyleOptionViewItem &option, const QModelIndex &index) const

            {

            /// Power
            if (index.column() == 2 ) {
                PowerEditor *editor = new PowerEditor(parent);
                editor->setWindowFlags(Qt::WindowStaysOnTopHint);
                return editor;
            }@
            

            Free Indoor Cycling Software - https://maximumtrainer.com

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on last edited by
              #6

              Since you want a widget that is outside, why not change the paradigm ? Make your editor a dialog and use the mouse events to open it. You can get the item under the mouse cursor and load your editor with it's data

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              1 Reply Last reply
              0
              • M Offline
                M Offline
                maximus
                wrote on last edited by
                #7

                I tried changing my custom editor to a QDialog instead of a QWidget. I am not sure what you mean but changing the paradigm; using window pop up when user click a cell? that would be too intrusive IMO, and having to close the editor each time you edit..

                Usually with Qt you can do anything if you are a bit "hacky". This is just a minor bug i'm trying to fix, I don't mind using a workaround, for example; if the popUp stays in the QTableView (like it his now), at least show a VerticalScroll bar so that user access the rest of my editor. Or maybe giving no parent to my editor, and setting the position manually on the cell, that way it is on top of the QTableView?
                Any suggestion, thanks SGaist!

                Here is my editor that I just converted to a QDialog, same behavior:

                @PowerEditor::PowerEditor(QWidget *parent) :
                QDialog(parent),
                ui(new Ui::PowerEditor)
                {
                ui->setupUi(this);

                setAutoFillBackground(true);
                setAttribute(Qt::WA_NoMousePropagation);
                setWindowFlags(Qt::WindowStaysOnTopHint);
                
                this->setModal(true);
                
                on_comboBox_power_currentIndexChanged(ui->comboBox_power->currentIndex());
                on_checkBox_balance_toggled(ui->checkBox_balance->isChecked());
                

                }@


                Free Indoor Cycling Software - https://maximumtrainer.com

                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  What about changing the row height so that your editor fits in ? Then you can use ensureVisible to have it completely on screen and when you're done, you bring it back to a suitable size.

                  Interested in AI ? www.idiap.ch
                  Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                  1 Reply Last reply
                  0
                  • M Offline
                    M Offline
                    maximus
                    wrote on last edited by
                    #9

                    I haven't thought of this, great idea! I'll make the row height a bit bigger and change my editor layout more rectangle than square and it should fit in ;)
                    ensureVisible is a property of what Widget? google didn't help me much on this one, thanks!


                    Free Indoor Cycling Software - https://maximumtrainer.com

                    1 Reply Last reply
                    0
                    • SGaistS Offline
                      SGaistS Offline
                      SGaist
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      My bad, it's scrollTo with the flag EnsureVisible, I've mixed that with QScrollArea, sorry.

                      Interested in AI ? www.idiap.ch
                      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      0

                      • Login

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Users
                      • Groups
                      • Search
                      • Get Qt Extensions
                      • Unsolved