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. Change Desktop Wallpaper
Forum Updated to NodeBB v4.3 + New Features

Change Desktop Wallpaper

Scheduled Pinned Locked Moved General and Desktop
40 Posts 5 Posters 21.0k 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.
  • QT-static-prgmQ QT-static-prgm

    It works :D Thank you very much.
    ähm ok i just wanted to press send and checked my cmd output and it "finished". But it says:

    jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtdeclarative\src\qml\Makefile.Debug [.generated\debug\RegExpJitTables.h] Error 1
    jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtdeclarative\src\qml\Makefile [debug-all] Error 2
    jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtdeclarative\src\Makefile [sub-qml-make_first-ordered] Error 2
    jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtdeclarative\Makefile [sub-src-make_first] Error 2
    jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\Makefile [module-qtdeclarative-make_first] Error 2

    A Offline
    A Offline
    amahta
    wrote on last edited by
    #13

    @QT-static-prgm check your build folder. Most probably you already have most of the libraries built. Continue with "jom install" command.
    But you can also check for dependencies and/or remove the module causing the problem, in this case it is qtdeclarative, and then rebuild.

    Thou shalt programme
    http://www.amin-ahmadi.com

    1 Reply Last reply
    0
    • QT-static-prgmQ Offline
      QT-static-prgmQ Offline
      QT-static-prgm
      wrote on last edited by
      #14

      -nomake qtdeclarative doesn't work :/

      • cd qtbase
      • C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtbase\configure.bat -top-level -static -debug-and-release -prefix "C:\Qt\5.5.1\msvc2015_static" -platform win32-msvc2015 -c++11 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -qt-sql-odbc -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests -nomake qtdeclarative
        Unknown part qtdeclarative passed to -nomake.
      A 1 Reply Last reply
      0
      • QT-static-prgmQ QT-static-prgm

        -nomake qtdeclarative doesn't work :/

        • cd qtbase
        • C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtbase\configure.bat -top-level -static -debug-and-release -prefix "C:\Qt\5.5.1\msvc2015_static" -platform win32-msvc2015 -c++11 -qt-zlib -qt-pcre -qt-libpng -qt-libjpeg -qt-freetype -opengl desktop -qt-sql-sqlite -qt-sql-odbc -no-openssl -opensource -confirm-license -make libs -nomake tools -nomake examples -nomake tests -nomake qtdeclarative
          Unknown part qtdeclarative passed to -nomake.
        A Offline
        A Offline
        amahta
        wrote on last edited by
        #15

        @QT-static-prgm It won't. You have to carefully read configure options. I suggest taking a look at this old post of mine about configure options. If I am not mistaken, you need to use "skip" instead of "nomake"

        Thou shalt programme
        http://www.amin-ahmadi.com

        1 Reply Last reply
        0
        • QT-static-prgmQ Offline
          QT-static-prgmQ Offline
          QT-static-prgm
          wrote on last edited by
          #16

          And again, thank you so much. What is qtdeclarative good for??

          A 1 Reply Last reply
          0
          • QT-static-prgmQ QT-static-prgm

            And again, thank you so much. What is qtdeclarative good for??

            A Offline
            A Offline
            amahta
            wrote on last edited by
            #17

            @QT-static-prgm it is related to QML. I usually can live without it :)

            Thou shalt programme
            http://www.amin-ahmadi.com

            1 Reply Last reply
            0
            • QT-static-prgmQ Offline
              QT-static-prgmQ Offline
              QT-static-prgm
              wrote on last edited by
              #18

              Next error:

              Error: dependent 'C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtdeclarative\lib\Qt5Qmld.lib' does not exist.
              jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtwebchannel\src\webchannel\Makefile [debug-all] Error 2
              jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtwebchannel\src\Makefile [sub-webchannel-make_first] Error 2
              jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtwebchannel\Makefile [sub-src-make_first] Error 2
              jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\Makefile [module-qtwebchannel-make_first] Error 2

              I think it's a kind of Windows 10 problem: https://forum.qt.io/topic/58056/compilation-failure-with-vs2015/3

              mrjjM 1 Reply Last reply
              0
              • QT-static-prgmQ QT-static-prgm

                Next error:

                Error: dependent 'C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtdeclarative\lib\Qt5Qmld.lib' does not exist.
                jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtwebchannel\src\webchannel\Makefile [debug-all] Error 2
                jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtwebchannel\src\Makefile [sub-webchannel-make_first] Error 2
                jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\qtwebchannel\Makefile [sub-src-make_first] Error 2
                jom: C:\Qt\5.5.1\qt-everywhere-opensource-src-5.5.1\Makefile [module-qtwebchannel-make_first] Error 2

                I think it's a kind of Windows 10 problem: https://forum.qt.io/topic/58056/compilation-failure-with-vs2015/3

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

                @QT-static-prgm
                HI just a side note:
                I used this on Win 7 to change wallpaper.
                (with mingw compiler)
                Never tested on window 10, so might not work.

                #include "mainwindow.h"
                #include <QApplication>
                #include <qDebug>
                
                #include <Windows.h>
                int setwallpaper (QString filePath ) {
                  bool ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID)filePath.utf16(), SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
                  return ret;
                }
                
                int main(int argc, char* argv[]) {
                  QApplication a(argc, argv);
                  MainWindow w;
                  w.show();
                  setwallpaper("c:/test.jpg"); // adjust
                  return a.exec();
                }
                
                
                1 Reply Last reply
                0
                • QT-static-prgmQ Offline
                  QT-static-prgmQ Offline
                  QT-static-prgm
                  wrote on last edited by
                  #20

                  Your code looks easy. I'll try it. But for now my program shown above is working with the VS compiler.

                  Thank you all :D

                  Ok next i'll try to manipulate the image to show the date and clock in the lower right corner. (my university killed the windows clock. That's why i need this ;))

                  mrjjM 1 Reply Last reply
                  0
                  • QT-static-prgmQ QT-static-prgm

                    Your code looks easy. I'll try it. But for now my program shown above is working with the VS compiler.

                    Thank you all :D

                    Ok next i'll try to manipulate the image to show the date and clock in the lower right corner. (my university killed the windows clock. That's why i need this ;))

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

                    @QT-static-prgm
                    hehe so you switch compiler and
                    compiled all of Qt so you can change
                    the wallpaper each minute and that way
                    get a clock ???
                    :))
                    That is the spirit if I ever saw one :))

                    but are you sure they allow to change the wallpaper?

                    QT-static-prgmQ 1 Reply Last reply
                    0
                    • mrjjM mrjj

                      @QT-static-prgm
                      hehe so you switch compiler and
                      compiled all of Qt so you can change
                      the wallpaper each minute and that way
                      get a clock ???
                      :))
                      That is the spirit if I ever saw one :))

                      but are you sure they allow to change the wallpaper?

                      QT-static-prgmQ Offline
                      QT-static-prgmQ Offline
                      QT-static-prgm
                      wrote on last edited by
                      #22

                      @mrjj
                      That's the aim :D

                      btw your code works fine as well. It is only faster then the other one. This:

                      #include "mainwindow.h"
                      #include <QApplication>
                      #include <QDebug>
                      #include "shobjidl.h"
                      #include <Windows.h>
                      
                      
                      int setwallpaper (QString filePath ) {
                        bool ret = SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID)filePath.utf16(), SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
                        return ret;
                      }
                      
                      
                      int main(int argc, char *argv[])
                      {
                      	HRESULT hr = CoInitialize(NULL);
                      	IDesktopWallpaper *pDesktopWallpaper = NULL;
                      	hr = CoCreateInstance(__uuidof(DesktopWallpaper), NULL, CLSCTX_ALL, IID_PPV_ARGS(&pDesktopWallpaper));
                      	if (FAILED(hr))
                      	{
                      		qDebug() << "error";
                      	}
                      	else
                      	{
                      		pDesktopWallpaper->SetWallpaper(NULL, QString("D:\\Bilder\\BMW\\3er nachher.jpg").toStdWString().c_str());
                      	}
                      
                      	qDebug() << setwallpaper("D:\\Bilder\\BMW\\f22-wallpaper-1920x1600-16.jpg");
                      
                      	return 0;
                      }
                      

                      causes in first shown the f22-wallpaper-1920x1600-16.jpg image and then 3er nachher. So maybe your code is better and that way there was no need to compile qt for vs.

                      But ok now i understand building qt a bit better XD

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

                        Ok. good to know,

                        Next its to create a timer object
                        http://www.bogotobogo.com/Qt/Qt5_QTimer.php
                        and then ( code not syntax checked)

                        // draw time on image
                        QPixmap pix("D:\\Bilder\\BMW\\3er nachher.jpg");
                        QPainter paint(pix);
                        QTime time = QTime::currentTime();
                        QString text = time.toString("hh:mm");
                        paint.drawText(pix.width()-100,pix.height()-20,text);
                        

                        and off u go :)

                        QT-static-prgmQ 1 Reply Last reply
                        2
                        • mrjjM mrjj

                          Ok. good to know,

                          Next its to create a timer object
                          http://www.bogotobogo.com/Qt/Qt5_QTimer.php
                          and then ( code not syntax checked)

                          // draw time on image
                          QPixmap pix("D:\\Bilder\\BMW\\3er nachher.jpg");
                          QPainter paint(pix);
                          QTime time = QTime::currentTime();
                          QString text = time.toString("hh:mm");
                          paint.drawText(pix.width()-100,pix.height()-20,text);
                          

                          and off u go :)

                          QT-static-prgmQ Offline
                          QT-static-prgmQ Offline
                          QT-static-prgm
                          wrote on last edited by
                          #24

                          @mrjj You saved my time. Thanks for the commands. I hope there are not too much questions tomorrow than i find some time to implement it in the cip-pool :D

                          mrjjM 1 Reply Last reply
                          0
                          • QT-static-prgmQ QT-static-prgm

                            @mrjj You saved my time. Thanks for the commands. I hope there are not too much questions tomorrow than i find some time to implement it in the cip-pool :D

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

                            @QT-static-prgm
                            Well its a good cause :)
                            Repel against the clock-less desktops!!
                            I think it would be the easiest to move all code to the timer object.
                            and let it draw on image then set it.
                            over and over :)

                            A 1 Reply Last reply
                            1
                            • mrjjM mrjj

                              @QT-static-prgm
                              Well its a good cause :)
                              Repel against the clock-less desktops!!
                              I think it would be the easiest to move all code to the timer object.
                              and let it draw on image then set it.
                              over and over :)

                              A Offline
                              A Offline
                              amahta
                              wrote on last edited by
                              #26

                              I'm glad the problem's solved. What @mrjj just mentioned is definitely much easier. My way was more like an example of using interfaces in Qt. They are of course more complicated but Windows API is changing so I guess you won't lose anything by seeing an interface example!
                              Good luck both

                              Thou shalt programme
                              http://www.amin-ahmadi.com

                              mrjjM 1 Reply Last reply
                              1
                              • A amahta

                                I'm glad the problem's solved. What @mrjj just mentioned is definitely much easier. My way was more like an example of using interfaces in Qt. They are of course more complicated but Windows API is changing so I guess you won't lose anything by seeing an interface example!
                                Good luck both

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

                                @QT-static-prgm said:
                                Yes, the use of interfaces is much more future
                                proof and also interesting to see used,
                                I also tried in mingw and it seems to think
                                IDesktopWallpaper was iUnknow no matter what i did.
                                So I guess Visual Studio is indeed better for win development.

                                1 Reply Last reply
                                0
                                • QT-static-prgmQ Offline
                                  QT-static-prgmQ Offline
                                  QT-static-prgm
                                  wrote on last edited by
                                  #28

                                  I tried the code yesterday. Nothing changed. It seams to be a problem of SystemParametersInfo. The function is too powerfull and was blocked. It returns always 0. :( will try the alternative version next

                                  mrjjM 1 Reply Last reply
                                  0
                                  • QT-static-prgmQ QT-static-prgm

                                    I tried the code yesterday. Nothing changed. It seams to be a problem of SystemParametersInfo. The function is too powerfull and was blocked. It returns always 0. :( will try the alternative version next

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

                                    @QT-static-prgm
                                    hi have you tried to manually set desktop wallpaper.
                                    If they removed the watch, they have might have
                                    taken right to set wallpaper also ?

                                    QT-static-prgmQ 1 Reply Last reply
                                    1
                                    • mrjjM mrjj

                                      @QT-static-prgm
                                      hi have you tried to manually set desktop wallpaper.
                                      If they removed the watch, they have might have
                                      taken right to set wallpaper also ?

                                      QT-static-prgmQ Offline
                                      QT-static-prgmQ Offline
                                      QT-static-prgm
                                      wrote on last edited by
                                      #30

                                      @mrjj I can manual change the wallpaper. That's no problem. They removed the clock because the Microsoft right handle doesn't work for them, so everyone who can see the clock and change it, too. Some students did that and that way the whole account synchronisation was broken. Since that the clock was removed.

                                      I tried to write the clock on the image at my home computer, but i get some errors for this step, too:
                                      QPixmap: Must construct a QGuiApplication before a QPixmap

                                      mrjjM 1 Reply Last reply
                                      0
                                      • QT-static-prgmQ QT-static-prgm

                                        @mrjj I can manual change the wallpaper. That's no problem. They removed the clock because the Microsoft right handle doesn't work for them, so everyone who can see the clock and change it, too. Some students did that and that way the whole account synchronisation was broken. Since that the clock was removed.

                                        I tried to write the clock on the image at my home computer, but i get some errors for this step, too:
                                        QPixmap: Must construct a QGuiApplication before a QPixmap

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

                                        @QT-static-prgm said:

                                        Must construct a QGuiApplication

                                        If you do have
                                        QApplication app( argc, argv );

                                        then you must likely have constructed the Pixmap as global before main.

                                        and hence its created before "app"

                                        QT-static-prgmQ 1 Reply Last reply
                                        0
                                        • mrjjM mrjj

                                          @QT-static-prgm said:

                                          Must construct a QGuiApplication

                                          If you do have
                                          QApplication app( argc, argv );

                                          then you must likely have constructed the Pixmap as global before main.

                                          and hence its created before "app"

                                          QT-static-prgmQ Offline
                                          QT-static-prgmQ Offline
                                          QT-static-prgm
                                          wrote on last edited by
                                          #32

                                          @mrjj It works now :D (on my home pc)

                                          #pragma warning(disable: 4100)
                                          #include <QGuiApplication>
                                          #include <QString>
                                          #include <QDebug>
                                          #include <QPixmap>
                                          #include <QTime>
                                          #include <QPainter>
                                          #include <Windows.h>
                                          #include "shobjidl.h"
                                          
                                          inline int setwallpaper(QString filePath)
                                          {
                                          	return SystemParametersInfo(SPI_SETDESKWALLPAPER, 0, (PVOID)filePath.utf16(), SPIF_SENDWININICHANGE | SPIF_UPDATEINIFILE);
                                          }
                                          
                                          
                                          void setWallpaperAdvanced(QString filePath)
                                          {
                                          	HRESULT hr = CoInitialize(NULL);
                                          	IDesktopWallpaper *pDesktopWallpaper = NULL;
                                          	hr = CoCreateInstance(__uuidof(DesktopWallpaper), NULL, CLSCTX_ALL, IID_PPV_ARGS(&pDesktopWallpaper));
                                          	if (FAILED(hr))
                                          	{
                                          		qDebug() << "error";
                                          	}
                                          	else
                                          	{
                                          		pDesktopWallpaper->SetWallpaper(NULL, filePath.toStdWString().c_str());
                                          	}
                                          }
                                          
                                          void drawTime(QPixmap &image, int posX, int posY, QColor color)
                                          {
                                          	QPainter painter(&image);
                                          	painter.setPen(color);
                                          	QFont font;
                                          	font.setBold(true);
                                          	painter.setFont(font);
                                          	QTime time = QTime::currentTime();
                                          	QDate date = QDate::currentDate();
                                          	QString timeText = time.toString("hh:mm");
                                          	QString dateText = date.toString(Qt::DefaultLocaleShortDate);
                                          
                                          	painter.drawText(posX+15,posY,timeText);
                                          	painter.drawText(posX,posY+15,dateText);
                                          }
                                          
                                          
                                          int main(int argc, char **argv)
                                          {
                                          
                                          	QGuiApplication a(argc, argv);
                                          	QString originalFilePath("D:\\workspaces\\Qt_default\\WallpaperApp\\wallpaper.jpg");
                                          	QString manipulatedFilePath("D:\\workspaces\\Qt_default\\WallpaperApp\\wallpaper_temp.jpg");
                                          
                                          	QTime time;
                                          
                                          	while(true)
                                          	{
                                          		time = QTime::currentTime();
                                          
                                          		if(time.second() == 0)
                                          		{
                                          			QPixmap image(originalFilePath);
                                          			drawTime(image, image.width()-75, image.height()-150, Qt::white);
                                          			image.save(manipulatedFilePath);
                                          			setWallpaperAdvanced(manipulatedFilePath);
                                          			qDebug() << "changed";
                                          		}
                                          		Sleep(800);
                                          	}
                                          
                                          	return 0;
                                          }
                                          
                                          

                                          I was just wondering if there is a good way to stop the program. Maybe a tray icon that has an close option. Any ideas??

                                          M 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