Radio button behavior in QWebView very odd



  • I created a simple form with some radio buttons inside a minimal QWebView application. The form has five radio buttons. When I click on the first radio button, the second one becomes selected. When I click on the second, the third is selected. If I click on the last radio button, they all deselect. This is strange because in other browsers the radio button I click on gets selected, not its neighbor.

    Here is my form:
    @
    <html>
    <head>
    <title>Fun</title>
    </head>
    <body>
    <form>
    <input type=radio name=position value='first'>First<br>
    <input type=radio name=position value='second'>Second<br>
    <input type=radio name=position value='third'>Third<br>
    <input type=radio name=position value='fourth'>Fourth<br>
    <input type=radio name=position value='fifth'>Fifth<br>
    <input type=submit value='Send it'>
    </form>
    </body>
    </html>@

    And here is my application:

    @
    #include "mainwindow.h"
    #include <QApplication>
    #include <QWebView>

    int main(int argc, char *argv[])
    {
    QApplication a(argc, argv);

    QWebView wv;
    wv.setHtml("&lt;html&gt; &lt;head&gt; &lt;title&gt;Fun&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form&gt; &lt;input type=radio name=position value='first'&gt;First<br> &lt;input type=radio name=position value='second'&gt;Second<br> &lt;input type=radio name=position value='third'&gt;Third<br> &lt;input type=radio name=position value='fourth'&gt;Fourth<br> &lt;input type=radio name=position value='fifth'&gt;Fifth<br> &lt;input type=submit value='Send it'&gt; &lt;/form&gt; &lt;/body&gt; &lt;/html&gt;");
    wv.show();
    
    return a.exec&#40;&#41;;
    

    }
    @

    This bug occurs with the 5.0.2 release of Qt downloaded from the Qt website. It appears on both Windows Vista and Windows 8. It appeared first on a much more complicated form, this is the simplest application I was able to create that illustrated the problem. I am completely unable to get radio buttons on QWebView to behave properly.

    Has anyone else had any luck with the QWebView radio buttons? Am I the only one having this problem? I've seen it on two separate machines. I tried using an html document that passed strict html validation from the WC3 site but that didn't change anything.

    Thank you for your help.



  • Hello ~francis_anthill
    Welcome to Qt Developer Network

    Maybe you should use different names for radio inputs? I hope it's going to help you.



  • Hi tucnak,

    I'm not sure I understood your reply. Do you mean that each input element should have a different value for "name"? This would not be correct, since in this case the radio buttons all need to have the same name in order to form a group. If each radio button in a group has a different name they will not be mutually exclusive.

    Or perhaps you meant that I should choose a different name instead of "position"? I have tried other names, but all seem to provide the same result.

    Is anyone else having this problem? I can't believe radio buttons could be this broken in webkit without anyone saying anything.



  • Heya

    IMHO it doesn't work like that. "name" attribute should be unique for all different radio buttons. Though, I am not sure about reasonabless of kinda mechanism here.

    I checked that on my machine, it works well (without name attributes). Try that



  • Hi I got some simliar errors, could the author of this thread resolve his issue?



  • Same here but with the newer qt 5.1.1 and under win7/8 .... Link to my bug report https://bugreports.qt-project.org/browse/QTBUG-34835



  • It's solved with a workaround explained here https://bugreports.qt-project.org/browse/QTBUG-34163


Log in to reply
 

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