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. No pen cursor n Qt library

No pen cursor n Qt library

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 5 Posters 326 Views
  • 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.
  • O Offline
    O Offline
    oneeyeman1
    wrote on 6 Mar 2025, 18:26 last edited by
    #1

    Hi,
    The documentation at https://doc.qt.io/qt-6/qt.html#CursorShape-enum does not display Pen Shaped cursor as a possible type.

    I'm working with X11/Linux and want to see if there is a possibilty of getting a pen shaped cursor (for drawing program).

    Thank you.

    P.S.: This is surprising as it is a fairly often used cursor shape...

    W 1 Reply Last reply 10 Mar 2025, 19:17
    0
    • S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 6 Mar 2025, 18:49 last edited by
      #2

      Hi,

      The most simple would be for you to provide that cursor in your application.

      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
      1
      • O Offline
        O Offline
        oneeyeman1
        wrote on 6 Mar 2025, 19:01 last edited by
        #3

        Hi,
        Are you saying that all those painting apps provide pen shaped cursor?
        And there is nothing like it inside X11/Wayland?

        Thank you.

        C 1 Reply Last reply 6 Mar 2025, 19:04
        0
        • O oneeyeman1
          6 Mar 2025, 19:01

          Hi,
          Are you saying that all those painting apps provide pen shaped cursor?
          And there is nothing like it inside X11/Wayland?

          Thank you.

          C Online
          C Online
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on 6 Mar 2025, 19:04 last edited by
          #4

          @oneeyeman1 said in No pen cursor n Qt library:

          Are you saying that all those painting apps provide pen shaped cursor?

          Why should the operating system provide application specific cursors? They must be provided by the application.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          1 Reply Last reply
          1
          • O Offline
            O Offline
            oneeyeman1
            wrote on 6 Mar 2025, 19:52 last edited by
            #5

            Hi,
            Im not asking for the OS - I'm asking for the library to provide a well known cursor for re'use on different apps.

            Moreover, most developers are not UI designer and create some bitmap/png/upgrade is a nightmare...

            Thank you.

            C 1 Reply Last reply 6 Mar 2025, 20:03
            0
            • O oneeyeman1
              6 Mar 2025, 19:52

              Hi,
              Im not asking for the OS - I'm asking for the library to provide a well known cursor for re'use on different apps.

              Moreover, most developers are not UI designer and create some bitmap/png/upgrade is a nightmare...

              Thank you.

              C Online
              C Online
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on 6 Mar 2025, 20:03 last edited by
              #6

              @oneeyeman1 said in No pen cursor n Qt library:

              I'm asking for the library to provide a well known cursor for re'use on different apps.

              What is 'well known cursor'? Who defines it?
              Qt is providing an abstraction to access the os cursors, nothing more and tbh I don't see why it should provide a set of some cursors for specific applications.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              1 Reply Last reply
              0
              • O Offline
                O Offline
                oneeyeman1
                wrote on 6 Mar 2025, 20:45 last edited by
                #7

                Hi,
                Then why do you provide all those cursor annum referenced at the link I gave in the OP?

                Now if you open for example Paint on Windows, it will start with the cursor represented as a pen. This pen is defined somewhere in the public Windows C/C++/Java/.NET/whatever API as well as the icon somewhere on the system.
                There is also an "I-beam: cursor with the same thing except that for some reason Qt provides enum definition for the "I-beam".

                Is there a possibility to retrieve the pen cursor icon from X11/Wayland?

                Thank you.

                C 1 Reply Last reply 7 Mar 2025, 05:13
                0
                • O oneeyeman1
                  6 Mar 2025, 20:45

                  Hi,
                  Then why do you provide all those cursor annum referenced at the link I gave in the OP?

                  Now if you open for example Paint on Windows, it will start with the cursor represented as a pen. This pen is defined somewhere in the public Windows C/C++/Java/.NET/whatever API as well as the icon somewhere on the system.
                  There is also an "I-beam: cursor with the same thing except that for some reason Qt provides enum definition for the "I-beam".

                  Is there a possibility to retrieve the pen cursor icon from X11/Wayland?

                  Thank you.

                  C Online
                  C Online
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on 7 Mar 2025, 05:13 last edited by Christian Ehrlicher 3 Jul 2025, 05:26
                  #8

                  Is there a possibility to retrieve the pen cursor icon from X11/Wayland?

                  What pen cursor are you referring here? X11 and wayland are window managers, they don't provide cursors.

                  Now if you open for example Paint on Windows, it will start with the cursor represented as a pen.

                  Here are the cursors provided directly by windows: https://learn.microsoft.com/de-de/windows/win32/menurc/about-cursors

                  As you can see there is no pen - Paint is a standalone program which ships it's own cursors.

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  P 1 Reply Last reply 7 Mar 2025, 06:43
                  1
                  • C Christian Ehrlicher
                    7 Mar 2025, 05:13

                    Is there a possibility to retrieve the pen cursor icon from X11/Wayland?

                    What pen cursor are you referring here? X11 and wayland are window managers, they don't provide cursors.

                    Now if you open for example Paint on Windows, it will start with the cursor represented as a pen.

                    Here are the cursors provided directly by windows: https://learn.microsoft.com/de-de/windows/win32/menurc/about-cursors

                    As you can see there is no pen - Paint is a standalone program which ships it's own cursors.

                    P Offline
                    P Offline
                    Pl45m4
                    wrote on 7 Mar 2025, 06:43 last edited by Pl45m4 3 Jul 2025, 06:44
                    #9

                    @Christian-Ehrlicher said in No pen cursor n Qt library:

                    As you can see there is no pen

                    Actually there is a pen icon (MAKEINTRESOURCE(32631)) defined in WinUser.h, but in the second table and it says that these icons don't have a specifier because they are not in use or not standard anymore.


                    If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                    ~E. W. Dijkstra

                    1 Reply Last reply
                    1
                    • O Offline
                      O Offline
                      oneeyeman1
                      wrote on 7 Mar 2025, 13:49 last edited by
                      #10

                      Hi,
                      As you can see from the OP, I don't work in windows with Qt - I use Linux.
                      So any chance I find this icon/pixmap on Linux somewhere?

                      Thank you.

                      P 1 Reply Last reply 7 Mar 2025, 13:56
                      0
                      • O oneeyeman1
                        7 Mar 2025, 13:49

                        Hi,
                        As you can see from the OP, I don't work in windows with Qt - I use Linux.
                        So any chance I find this icon/pixmap on Linux somewhere?

                        Thank you.

                        P Offline
                        P Offline
                        Pl45m4
                        wrote on 7 Mar 2025, 13:56 last edited by
                        #11

                        @oneeyeman1 said in No pen cursor n Qt library:

                        So any chance I find this icon/pixmap on Linux somewhere?

                        If you don't check you will never know :)
                        Go where the icons are stored for your Linux distro...
                        As there was said before... if there isn't such standard icon, you have to create your own cursor set and ship it with your app... like most painting tools, games and other programs do


                        If debugging is the process of removing software bugs, then programming must be the process of putting them in.

                        ~E. W. Dijkstra

                        1 Reply Last reply
                        0
                        • O oneeyeman1
                          6 Mar 2025, 18:26

                          Hi,
                          The documentation at https://doc.qt.io/qt-6/qt.html#CursorShape-enum does not display Pen Shaped cursor as a possible type.

                          I'm working with X11/Linux and want to see if there is a possibilty of getting a pen shaped cursor (for drawing program).

                          Thank you.

                          P.S.: This is surprising as it is a fairly often used cursor shape...

                          W Offline
                          W Offline
                          wrosecrans
                          wrote on 10 Mar 2025, 19:17 last edited by
                          #12

                          @oneeyeman1 When I want a "familiar" but not universal icon for my application, I usually start by checking to see if there's an emoji that will work. You can render that from text using your favorite font with that character and set it as a custom cursor.

                          Here's a somewhat janky utility function I have that you might find useful as a starting point. I use Font Awesome as my default font for UI symbol stuff and bundle it with the app, but you can specify whatever font when doing this sort of thing. It includes stuff like paintbrush icons, and a zillion other things that you might want https://fontawesome.com/icons/paintbrush?f=classic&s=solid

                          If you are using standard emoji, you can even type them directly into your source code these days and do stuff like

                          auto myBrushIcon = to_Icon("🖌")
                          
                          
                          QIcon to_Icon(const std::string text, int size=64, std::string font="Font Awesome 5 Free", QColor background = QColor(255, 255, 255, 128));
                           ///
                          
                          QIcon to_Icon(const std::string text, int size, std::string font, QColor background)
                          {
                              QPixmap pm(size, size);
                              pm.fill(Qt::transparent);
                          
                              QPainter p(&pm);
                              int margins = 0;
                              p.fillRect(margins, margins, size-margins, size-margins, background);
                          
                              QFont icon_font;
                              if (font != "") {
                                  icon_font.setFamily(font.c_str());
                              }
                          
                              icon_font.setPixelSize(size*.75);
                              icon_font.setWeight(0);
                              p.setFont(icon_font);
                          
                              QFontMetrics metrics(icon_font, &pm);
                              auto y = metrics.height();  // descent();
                              auto x = metrics.width(QString::fromStdString(text));
                              x = metrics.horizontalAdvance(QString::fromStdString(text));
                              auto offset = (size-x) / 2; // size - y - 1
                              p.drawText(offset, y, QString::fromStdString(text));
                          
                              p.end();
                              return QIcon(pm);
                          }
                          
                          1 Reply Last reply
                          0

                          5/12

                          6 Mar 2025, 19:52

                          • Login

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