Important: Please read the Qt Code of Conduct -

Taskbar event

  • Hello! Excuse me, I removed the system frame of the Qt program, and then customized the minimize button to minimize the program when I clicked it. The program is restored when clicking the program from the task bar. How can I know that the user clicked on the program from the taskbar?

  • Lifetime Qt Champion

    Normally you cant as such.
    you can try

     in .h . in class.
        void changeEvent(QEvent *e) override;
    then in .cpp
    void MainWindow::changeEvent( QEvent* e )
        if( e->type() == QEvent::WindowStateChange )
            QWindowStateChangeEvent* event = static_cast< QWindowStateChangeEvent* >( e );
            if( event->oldState() & Qt::WindowMinimized )
                qDebug() << "Window restored (to normal or maximized state)!";
            else if( event->oldState() == Qt::WindowNoState && this->windowState() == Qt::WindowMaximized )
                qDebug() << "Window Maximized!";

    and see if you can use that to know user restored the window.

  • Thank you very much, the problem has been resolved following your instructions.
    Please forgive me for asking new questions directly here instead of through new posts.
    The font of each sub-item in the menu bar of the QMainWindow program will become larger as the system resolution becomes larger. I didn’t want him to grow bigger, so I used a style sheet
    "font-family: Microsoft YaHei UI;"
    "font-size: 12px;"
    "color: rgb(221, 221, 221);"
    But I found that setting the border color is OK, but the font size doesn't seem to work.
    What is the solution?

  • Lifetime Qt Champion


    To style the QMenus, you can use

    QMenu::item {
    font-family: Arial; 
    font-size: 13pt; 
    border: 1px solid red; 

    alt text

    and also
    to set the top menus.

  • @mrjj said in Taskbar event:


    I tried your method, but it was not as expected.
    Please click on the link. This is a few seconds of video I recorded to illustrate my problem.
    Extraction code: 0000
    In the video, the first time the screen was run at 100% resolution, and then switched to 125%, I found that the font of the menu bar became significantly larger. I don’t want him to be bigger. No matter how big the screen resolution is, let him keep the size of 100% resolution. How to set it?

  • Lifetime Qt Champion

    ahh the windows text scale. super with video. makes much easier to understand.

    You can try to use pixel size for the font
    I have not tested it lately but it used to work.

    or disable scaling

    Not sure what else we can do as its supposed to scale the fonts.

  • Thank you very much, the previous question has been solved according to your instructions.
    A good day starts from asking questions, hahaha. . .
    Excuse me, I removed the built-in system border to keep the style consistent under Windows 7 and Windows 10. But there is no shadow.
    I have tried several ways, such as form nesting Widget way and so on. But the result was not satisfactory. Is there a better way to add window shadows without borders? Links to related articles are also available.

  • Lifetime Qt Champion

    Good to hear.

    -A good day starts from asking questions, hahaha. . .
    Hehe sounds like a Chinese saying :) 一笑解千愁。

    • Is there a better way to add window shadows without borders?

    Well I'm not even sure it's possible to make Windows draw the drop shadow when there is no borders.

    I only saw people using Effects to fake it.

    the link to the zip can give you

    alt text

    alt text

  • Hi, the charming me has appeared again.
    I want to automatically pop up a sub-window after the main window is fully displayed.
    So the question is, how to judge whether the main window is fully displayed?

  • Lifetime Qt Champion

    @Nan-Feng said in Taskbar event:


    So the question is, how to judge whether the main window is fully displayed?

    Override showEvent
    for MainWindow

  • I heard that the harder the people in Qt work, the more salaries they will get. So recently you have helped me a lot. I am here to help you.
    Excuse me, can QDockWidget remove the border (title bar, floating button, close button)? I want to maintain a consistent style on all PC platforms. I want to draw the title bar, floating button, and close button by myself. Where is there such an example link or article? After redrawing, close to the edge of the main window, how to connect the floating function of the floating button with the corresponding function?

  • Lifetime Qt Champion


    Hehe. well this is a user-driven forum so none of here get money from Qt company. Its purely by
    using one's own free time.

    -how to connect the floating function of the floating button with the corresponding function
    You mean dockWidget->setFloating(true/false);
    As to reimplement the buttons in your new titlebar widget ?

  • Hi, the problem of QDockWidget is solved. I want to display the compilation time of the program on a QLabel. I remember there seems to be a macro that can be implemented, right? Which is it?

  • Lifetime Qt Champion

  • Widget controls nested QDockWidget that thing... the text description is all on the picture

    Extraction code: 0000

  • Lifetime Qt Champion


    You cannot put a QDockWidget like that as it then becomes
    a "normal" Widget and cant undock/float. Bascially Docks can only be insert around the center but not directly
    covering all of it.

    You could use

    Which I think can dock any way you wish.

  • Good fellow, I'll call you good fellow. There are people outside, and the layout is all handwritten.
    By the way, what time is it on your side now? I found that you are usually online at night, is it due to the time difference or you have time at this time of the day. Today you are also working hard~~ Yesterday’s compilation time problem, DATE can be obtained, but the format is not the format I want, is there any way to convert the format? For example, to 2021-7-16

  • Lifetime Qt Champion

    Its due to the time diff. Im never awake in the night anymore. My job moved so i have to get up
    at 5.30 in the morning so I have to sleep long before night time. :)

    -Yesterday’s compilation time problem, DATE can be obtained, but the format is not the format I want, is there any way to convert the format?

    Did you use the 
     message($$system(date +"'%d-%m-%y %T'"))
    or the 
    QString datetime = QStringLiteral(__DATE__) + QStringLiteral(" ") + QStringLiteral(__TIME__);
    way ?


     auto test = QLocale("en_US").toDate(QString(__DATE__).simplified(), "MMM d yyyy");
     QString timestamp ( test.toString( Qt::ISODate) + QStringLiteral(" ") + QStringLiteral(__TIME__) );
     qDebug() << timestamp;
    gives:  2021-07-16 15:50:55

    For "date +"'%d-%m-%y %T'" way, you can adjust the order of the % tags to format how you want. d = day , m = month and y = year

  • Thanks, solved. So happy~
    moved? Hahaha, congratulations to the boss for mentioning the new house~ envy.
    Hearing that you moved to a new house, I was so excited that I forgot what the problem was. . . .

  • Lifetime Qt Champion

    Actually, it was Job location. moved from local city to Copenhagen city.
    so I have to drive much longer. But on the plus side. the new office is much nicer :)

    Good, you found solution. Happy programming.

  • Hi, good morning. I have been looking forward to this moment. . . You have all moved to the capital, and the future can be expected!
    I encountered a few more problems.

    1. Is there a link to an article or example of a custom file dialog?
    2. What is the general program version number calculated based on, for example,, I saw, how are 5588 and 6287 come out here? Of course, this is just what I saw, you don’t have to answer this. You can also talk about your calculation method.
    3. Like the one in the picture, what controls should be used for foldable and expandable ones?
      Extraction code: 0000
    4. Where is there a plug-in for the Sqlite database with a password (5.15.2 MSVC 32Bit or 64Bit), if not, where can I compile a plug-in article with a password?

  • Lifetime Qt Champion



  • My God, I think you must have been very busy yesterday.
    A few questions just now have been understood. And will try to realize it tomorrow.
    There are some video encryption software on the market, and the encrypted video files generated by those software are in .exe format. Probably the video was re-encoded and then covered with a shell. Then when running the playback, the playback password verification is performed first, and the playback is correct if it is correct.
    How should this operation of nesting files into .exe be implemented? Are there any related articles for me to study and study?

  • Lifetime Qt Champion

    Yes i did garden work for like 10 hours. :)

    There are many this this can be done.
    One is to convert the data to code
    Other can be like some installers do it

    Qt has a resource system that allows data to be included in the exe.

    But is this for your sqllite DB ?

  • It's still this time and this place, old iron. I'm coming~~~
    Tangtang Qt God actually went to do gardening work. Isn't it a pity.

    1. Which collapsible control I have made using QTreeWidget is basically normal. The problem now is that the horizontal position between the controls will not change with the layout of the form, even if I have set the horizontal layout of the form. Please watch the video.
      Extraction code: 0000
    2. Are there any articles or examples based on the timeline of the QSlider control? I found a PySide2 here, I want to change to pure Qt, but it failed, hahaha. . This is the link

  • @mrjj 1. Hey, no one cares about the post when I wake up in the morning. So I ordered a song for you. Express my miss for you, haha~ Music address

    I want to use the addChild function to add a Widget control in a TopLevelItem of QTreeWidget. But it doesn't seem to work. The purpose of adding Widget control is that I want to add layout and some buttons in it. What is the solution?
    2. Does QMediaPalyer not have its own decoder? I tried to play the video, but the program console output DirectShowPlayerService::doRender: Unresolved error code 0x80040266 or DirectShowPlayerService::doSetUrlSource: Unresolved error code 0x80004005 () Does the network say there is no decoder? So I downloaded LAVFilters. Played normally. But I don't like this very much. Are there any articles and examples of Qt and gstreamer playing videos and manipulating videos? On the window platform. The reason why I don't want to use LAVFilters is that the dialog boxes in some of his libraries are easily modified by decompilation. I don't like this very much. Or Qt and other media libraries are also possible.

  • Lifetime Qt Champion

    1: hehe that was actually very emotional even i didn't understand a word. :)

    • The problem now is that the horizontal position between the controls will not change with the layout of the form, even if I have set the horizontal layout of the form.

    Hmm Did you use the red layouts ? i mean does the horizontal layout show as red lines and you are using the Designer / UI ?
    If yes, its due to the red layout being for inserting into other layouts.
    One should assign the layout to a form using the Right click menu,.
    If no, i need more info on the issue :)

    2: It been asked a few times but I dont know any "just works" Widgets to use.


    • I want to use the addChild function to add a Widget control in a TopLevelItem of QTreeWidget. But it doesn't seem to work. The purpose of adding Widget control is that I want to add layout and some buttons in it. What is the solution?

    In which way "But it doesn't seem to works" ?
    There are 2 ways to add Widgets to view. The best being a delegate.
    or using
    Which does allow widgets in views but is also heavy for small devices. (if many rows)

    No. It uses the backbone support's render and the codecs that is available via it.
    There is some that have compiled it for windows
    But its not that easy.

  • Hi, good morning. I made a picture to provide you with what I want to do.
    In this picture, the "Effect Pressets & Docs" node in QTreeWidget should be TopLevelItem and there are many buttons expanded, here it should be child. I want to use QTreeWidget to achieve such a function. That should add a Widget as a child. According to your reply, my attempt failed, and then I was stupid looking for such articles on GitHub, but I didn't find it. Can you not even write an example? Or find a similar example.
    Picture preview:

  • Lifetime Qt Champion

    Before we dive into QTreeWidget, which should work too.
    I wanted to tell you about
    which is actually a collapse widget.
    alt text

    I first realize now that this might also work for your use case.

  • Hi, I tried this QToolBox control. When there is only one page, it cannot be collapsed. In addition, this control does not seem to be able to expand multiple pages at the same time. It would be perfect if it could expand multiple pages at the same time.
    QTreeWidget's addchild Widget How is your research there?

  • Lifetime Qt Champion

    Ok. yes, it would be great if it could have multiple open pages but it seems it was a not goal.

    • QTreeWidget's addchild Widget How is your research there?

    Well you can just call
    tree->setItemWidget(item,0, new SomeWidget );

    alt text

    example project:

  • Hi, I found a phenomenon. As long as you reply to the news at night, it is the best. Did my problem keep you awake at night? Hahahaha~
    In the past few days, I tried FFMpeg, QTAV, and other frameworks for playing videos. Do you have any recommendations for simple and easy-to-use video frameworks?

  • Lifetime Qt Champion

    Hehe well, i think the time diff is so big that when it's day here , it's night at your place.

    Those are the best ones.

    There is also
    but it seems they didn't update it much so might not be up to snuff.

    What was wrong with QtAV ? I heard good things about it but i never tried it.

  • Hi, how about I haven't contacted you for a few days? It's really like not asking questions in a day like three autumns. Ha ha! !
    Everything went well, but there were still two problems.

    1. I used VLC to play the video, but I want to open a separate thread for playing the video, but I have no idea. The reason is that there is only one function (such as the run() function) in the new thread for work, but for video operations, there are play and pause. Mute and other operations. These will not have to be written in the thread's work function (such as the run() function). There are articles or examples about not using the main thread, but using a new thread to play videos and other operations. My main reason is that there is some confusion.
      There are a lot of things similar to buttons at the bottom of this picture, which can also be dragged to the right and connected. What is this? What control is the container that stores these buttons? How to set the style of these buttons, it seems that this is not something that a style sheet can make. Please give me an example of this.

  • Lifetime Qt Champion


    1. Often encoding/encoding is moved to another thread and frames are sent to the display widget in the GUI thread. Not the whole player.

    • What control is the container that stores these buttons?
      It's hard to say. it's a custom control of sorts. Does it seem to have categories in top?
      You can use a listwidget (in icon mode) or ScrollArea to build such a container.

    • How to set the style of these buttons,
      Custom widget - that can draw the borders this way. Not sure the color tags can be made
      with stylesheets. Also, they can be connected to the color tags so overall it's a custom control.

    Also be aware of
    which also is good for such editors.

    You might be able to use something like

  • Hi, good morning. Today I started to learn QtQuick, because I found that my requirements for the UI are really higher, or QtQuick is more suitable for my needs.
    What I want to ask is, can you recommend several QtWidget sample programs that confuse file compression and encryption? This is very important. Trouble you

  • Lifetime Qt Champion

    Well QML is good for special interfaces as it allows custom drawing a lot.
    just in case you didn't see:

    Often its not a QWidget but a library for both compression and encryption.

    for zipping, many use

    for light encryption
    for heavy

    There are many other libs.

  • Great, did you wake up in the middle of the night again? You will always bring surprises when you wake up in the middle of the night.
    I found that the QtQuick program will release some .qmlcache files in a folder under the %localappdata% path. I checked the information and said it was used to speed up the virtual speed of program startup. Can this file release path be set? If not, which file is the Qt source code of this file location decided to release?

  • Lifetime Qt Champion

    heh nope. I rarely am up late anymore. used to do it a lot but not the last 10 years :)
    But you must be up late then :)
    You can use QML_DISK_CACHE_PATH to set the path.

  • Hi, I am trying to use Qml to make a Css form, as in the video, I added a blur effect, but why the blur is not what I want in the future. What I want is a circular blur, just like in the video. In addition, after running the mouse drag a few times, it got stuck for a while, and the blur effect disappeared! ! If the mouse changes the size of the form, the blur effect will also disappear. What's the situation?
    Video link: 16-09-44.mp4

    My code:

    id: _app
    width: 1200
    height: 800
    visible: true
    title: "Most Creative Profile Card Design"

        anchors.fill: parent
            id: _imgRect
            x: _bgRec.x + _bgRec.width / 2-width / 2
            y: _bgRec.y-height / 2
            width: 120
            height: 120
            color: "#00FF00"
            radius: 60
            z: 1
                anchors.fill: parent
                source: parent
                radius: 20
            id: _bgRec
            anchors.centerIn: parent
            width: 450
            height: 350
            color: "#FFE4E1"
            z: 0


Log in to reply