Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Create top level widgets in QT application (draggable)



  • I want to create a widget which sits on the top level of the application.
    LIKE
    6c7158c5-03d9-4615-a2d1-d061a4719512-image.png

    Which on click
    Should be like this.
    2f4a516d-5b58-4cbb-9ee1-f0c2070ba44f-image.png

    This is actually written with HTML CSS and JavaScript.
    I want same like features and drag able.
    Like when I clicked button
    It should just open slowly and again on closing it should collapse slowly

    Which one QTWidgets or QML
    I hope to see this one in QtWidgets


  • Lifetime Qt Champion

    @Thank-You
    Hi
    That's comes from you putting in a layout. Then its no longer floating as before and i think
    it alters how it can show its menus. At least that is my guess as i didn't see the submenus do anything like that.


  • Lifetime Qt Champion

    Hi,

    Maybe the PieMenu will fit your needs.


  • Lifetime Qt Champion

    Hi
    Doing this is QWidgets is not so easy as floating a widget over all widgets will have some
    issues.



  • @SGaist
    Yes That's good.
    But It would be great if I got some thing like this in Widgets
    @mrjj
    I guess I should shift to QML now. πŸ˜‚πŸ˜‚


  • Lifetime Qt Champion

    There's an old Qt Quarterly article which covers pie menu. It's from a time where QtQuick was not even an idea yet.


  • Lifetime Qt Champion

    Hi
    I download the code from @SGaist link and discovered it was based on something called
    QtPieMenu.
    I then goggled
    https://github.com/mola/QtPieMenu

    Which just needed some include fixed and then it ran

    alt text

    ps . i added as it was undefined and not in either math and cmath

    #ifndef M_PI
        #define M_PI 3.14159265358979323846
    #endif
    
    


  • @mrjj
    Yes I built it succesfully
    with these improvements

    //#include <QtGui/QApplication>
    #include<QApplication>
    #include <QtGui/QImage>
    #include <QtGui/QBitmap>
    #include <QtCore/QPointer>
    #include <QtGui/QCursor>
    //#include <QtGui/QStyle>
    #include<QStyle>
    #include <QtGui/QPainter>
    #include <QtGui/QIcon>
    #include <QtGui/QTextLayout>
    //#include <QtGui/QLayout>
    //#include <QtGui/QDesktopWidget>
    

    I just changed some of header files See commented files are not available so I replaced them with others

    347f7ced-9672-4696-b231-47713e3d7aa6-image.png

    b3128073-8fad-4a76-9c32-130180264dd8-image.png

    Another Problem

    • When I click on menus the menu disappears

    See here This is not working what I was expecting

    I am using QT 5.12.8
    and it is built using

    QT 512.8 MSVC 2015

    I define M_PI too as said by @mrjj

    \qtpiemenu.cpp:600: warning: 'screenNumber' is deprecated
    C:\Qt\Qt5.12.8\5.12.8\msvc2015_64\include\QtCore\qcompilerdetection.h:1203: expanded from macro 'Q_DECL_DEPRECATED_X'
    C:\Qt\Qt5.12.8\5.12.8\msvc2015_64\include\QtWidgets\qdesktopwidget.h:77: 
    'screenGeometry' has been explicitly marked deprecated here
    // it says these issues
    

    The menus are not working properly


  • Lifetime Qt Champion

    @Thank-You
    Hi
    the deprecated warnings you can ignore.
    Just means the function will be removed at some point.

    • The menus are not working properly

    Ok. Sad - It was somewhat close to what you asked- i think :)

    alt text

    It seems to work for me. but I didn't try to insert my own menus to it and
    "not working properly" does really not hint at what you experienced.



  • @mrjj
    I also didn't insert my own menus too.

      QVBoxLayout *lt = new QVBoxLayout(ui->centralWidget);
      lt->addWidget(root);
      ui->centralWidget->setLayout(lt);
    

    This is the only thing that I added. I forgot to mention this. It was not showing any thing before adding this code here.

    It was just showing blank screen at that time

    And another thing is
    When you click the button it disappears.

    I guess it exists in your video too


  • Lifetime Qt Champion

    Good morning

    • It was just showing blank screen at that time

    I have to right click to show it. It then comes where you click

    • When you click the button it disappears.
      Yes when you select an End menu (one that has no subitems) , you select it when you click it and then it closes a a menu normally does.

    Is that what you mean or does it close in odd places also for you ?

    update:

    void  QtPieMenu::subMenuSelected()
    {
      emit  activated();
      emit  aboutToHide();
      //----->>>> hide();   if you take out this it wont close
    }
    


  • @mrjj

    I have to right click to show it. It then comes where you click

    I didn't know about that. It's working fine in this condition

    //----->>>> hide(); if you take out this it wont close

    Yes it is also working. Thanks.

    But the main problem is styling
    87df3481-fe99-4d73-b069-b9a778ba8eb1-image.png

    See when I full screen the application. It seems to come somewhere near it but not like what is in your machine

    8bb1ce8a-b558-4527-8db6-6f2a898d054e-image.png

    See this one too. It is not that good


  • Lifetime Qt Champion

    @Thank-You
    Hi
    That's comes from you putting in a layout. Then its no longer floating as before and i think
    it alters how it can show its menus. At least that is my guess as i didn't see the submenus do anything like that.



  • @mrjj

    That's comes from you putting in a layout. Then its no longer floating as before and i think

    Exactly Bro

    I have to right click to show it. It then comes where you click

    At first I didn't know about it. It was just blank before So I added it to layout so that it would be shown.

    So that's the problem in my code.
    It's working perfectly fine.

    One thing would be greater.
    The anti aliasing feature would be great. It doesn't look that much perfectπŸ˜‚πŸ˜‚πŸ˜‚
    It's just for design issue.

    And another thing just about this forum.

    I should have marked answer to post with link but I accidentally clicked another one. Is there way to revert it.

    https://github.com/mola/QtPieMenu


  • Lifetime Qt Champion

    @Thank-You
    Hi
    ok. super.

    • The anti aliasing feature would be great. It doesn't look that much perfect
      I agree. I think it comes from using the mask and its floating. Then it cant
      smooth it as much as normally. Could most likely be helped with a thigger line or
      some tweaking.

    • I should have marked answer to post with link but I accidentally clicked another one. Is there way to revert it.
      Im not sure how to undo it as not even admins have options for that. and it has no side menu.


Log in to reply