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. Problem with SpinBoxes delegate and TableWidgets
Forum Updated to NodeBB v4.3 + New Features

Problem with SpinBoxes delegate and TableWidgets

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 3 Posters 2.7k Views 3 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.
  • OlivierDuguayO Offline
    OlivierDuguayO Offline
    OlivierDuguay
    wrote on last edited by
    #1

    Hi, I wonder if somebody know why, when I call the function :

    ui->tableWidget->openPersistentEditor(ui->tableWidget->item(rowIdx,columnIdx));

    on my QTableWidget which contains a QSpinBox delegate, exactly the same as this example : SpinBox delegate example from Qt IO

    the SpinBoxes are always hightlighted/selected.... (in light blue since I use Windows)

    I wonder if there is any way I could change this behavior... In fact, it seems like it is the QLineEdit that is selected in the spinbox and the not the spinbox itself.... I tried to deselect()it after the call for the openPersistentEditor but no luck...

    Is there a trick with the QStylesheet (I already tried a couple thing with the Spinboxes, but again, no luck with that).... or maybe there's something I could do with the repaint of the widget... I really don't know at that point...

    Thank you all for any help !

    Olivier Duguay

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

      Hi,

      What version of Qt are you using ?
      On what OS ?

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

      OlivierDuguayO 1 Reply Last reply
      1
      • SGaistS SGaist

        Hi,

        What version of Qt are you using ?
        On what OS ?

        OlivierDuguayO Offline
        OlivierDuguayO Offline
        OlivierDuguay
        wrote on last edited by
        #3

        @SGaist I'm currently using Qt Creator 4.2.1 on Windows 10, and the project is made with Qt 5.7.1MSVC2015_64bit (and will be use only on Windows machine)

        Olivier Duguay

        1 Reply Last reply
        0
        • mrjjM Offline
          mrjjM Offline
          mrjj
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Hi
          I dont have windows to test on, but is that not normal for edit?
          Just the focus color.
          If it should not have focus, when should it do then ?

          OlivierDuguayO 1 Reply Last reply
          0
          • mrjjM mrjj

            Hi
            I dont have windows to test on, but is that not normal for edit?
            Just the focus color.
            If it should not have focus, when should it do then ?

            OlivierDuguayO Offline
            OlivierDuguayO Offline
            OlivierDuguay
            wrote on last edited by
            #5

            @mrjj I guess this is the normal behavior... but I also created some QTimeEdit and QComboBoxes delegate and they don't seems to be selected on focus as compared to the QSpinboxes... that's why I'm a bit confused... but it doesn't really matters if it get "on focus/selected", as long as I can programmatically deselect them after... which I didn't find any solution for .

            Olivier Duguay

            mrjjM 1 Reply Last reply
            0
            • OlivierDuguayO OlivierDuguay

              @mrjj I guess this is the normal behavior... but I also created some QTimeEdit and QComboBoxes delegate and they don't seems to be selected on focus as compared to the QSpinboxes... that's why I'm a bit confused... but it doesn't really matters if it get "on focus/selected", as long as I can programmatically deselect them after... which I didn't find any solution for .

              mrjjM Offline
              mrjjM Offline
              mrjj
              Lifetime Qt Champion
              wrote on last edited by
              #6

              @OlivierDuguay

              hi
              in the delegate, try call setFocus() on something else after creating the spinedit.
              or try the clearFocus() call.

              OlivierDuguayO 1 Reply Last reply
              0
              • mrjjM mrjj

                @OlivierDuguay

                hi
                in the delegate, try call setFocus() on something else after creating the spinedit.
                or try the clearFocus() call.

                OlivierDuguayO Offline
                OlivierDuguayO Offline
                OlivierDuguay
                wrote on last edited by
                #7

                @mrjj Just try both, it doesn't work (tried clearFocus() on the spinbox after is creation, and tried the setFocus() on another widget (a QPushbutton outside the QTableWidget) and even both at the "same time" but still no luck :(

                Olivier Duguay

                OlivierDuguayO 1 Reply Last reply
                0
                • OlivierDuguayO OlivierDuguay

                  @mrjj Just try both, it doesn't work (tried clearFocus() on the spinbox after is creation, and tried the setFocus() on another widget (a QPushbutton outside the QTableWidget) and even both at the "same time" but still no luck :(

                  OlivierDuguayO Offline
                  OlivierDuguayO Offline
                  OlivierDuguay
                  wrote on last edited by
                  #8

                  Even tried this in the delegate...

                  spinBox->findChild<QLineEdit*>()->clearFocus();
                  

                  Olivier Duguay

                  mrjjM 1 Reply Last reply
                  0
                  • OlivierDuguayO OlivierDuguay

                    Even tried this in the delegate...

                    spinBox->findChild<QLineEdit*>()->clearFocus();
                    
                    mrjjM Offline
                    mrjjM Offline
                    mrjj
                    Lifetime Qt Champion
                    wrote on last edited by
                    #9

                    @OlivierDuguay

                    Ok, so focus is sat either multiple times or after the statement.
                    I assume the Spin Box Delegate Example is a good test case as it does the same ?

                    OlivierDuguayO 1 Reply Last reply
                    1
                    • mrjjM mrjj

                      @OlivierDuguay

                      Ok, so focus is sat either multiple times or after the statement.
                      I assume the Spin Box Delegate Example is a good test case as it does the same ?

                      OlivierDuguayO Offline
                      OlivierDuguayO Offline
                      OlivierDuguay
                      wrote on last edited by
                      #10

                      @mrjj It's call'd after since I tried to change the selection in a slot called by valueChanged(double) of the QDoubleSpinbox but the selection is made after this signal is called...

                      Olivier Duguay

                      mrjjM 1 Reply Last reply
                      0
                      • OlivierDuguayO OlivierDuguay

                        @mrjj It's call'd after since I tried to change the selection in a slot called by valueChanged(double) of the QDoubleSpinbox but the selection is made after this signal is called...

                        mrjjM Offline
                        mrjjM Offline
                        mrjj
                        Lifetime Qt Champion
                        wrote on last edited by mrjj
                        #11

                        @OlivierDuguay

                        ok a bit odd then.
                        if u make a spinedit your self and test with. it does same ?

                        1 Reply Last reply
                        1
                        • OlivierDuguayO Offline
                          OlivierDuguayO Offline
                          OlivierDuguay
                          wrote on last edited by
                          #12

                          Seems like it.... It come from the openPersistentEditor.... anyways, for now, I think I'll just change the default QStyleSheet at the creation of the Spinbox, and then change it back when the widget is accessed !... very weird !...

                          Olivier Duguay

                          1 Reply Last reply
                          1

                          • Login

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