Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Qt4 dialog style set to default after UWP conversion

    General and Desktop
    2
    13
    2987
    Loading More Posts
    • 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.
    • S
      Stak1945 last edited by

      I asked the same question at Windows Dev Center as well but no answer yet. Hope the Qt side can give some insight into this.
      https://social.msdn.microsoft.com/Forums/windowsapps/en-US/02937f15-83bf-4362-b20e-a9b8ae91fcb3/uwpdesktop-bridgewrong-qt-dialog-style?forum=wpdevelop

      We have an application built by Qt4. After converting from original Win32 applicatioin to UWP, all the dialogs handled by Qt itself are reset to the default style.
      Before Convertion (Win32):
      Before Convert
      After Convertion (UWP):
      After Convert (UWP)

      I wrote a very simple demo application and after conversion the same problem recurred.
      Win32:
      Win32
      UWP:
      UWP

      The demo code:

      #include <qapplication.h>
      #include <QPushButton>
      #include <QHBoxLayout>
      #include <QSlider>
      #include <QSpinBox>
      
      int main(int argc, char**argv)
      {
      	QApplication app(argc, argv);
      	QWidget* window = new QWidget;
      	window->setWindowTitle("Enter Your Age");
      
      	QSpinBox* spinBox = new QSpinBox;
      	QSlider* slider = new QSlider(Qt::Horizontal);
      	spinBox->setRange(0, 130);
      	slider->setRange(0, 130);
      
      	QObject::connect(spinBox, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
      	QObject::connect(slider, SIGNAL(valueChanged(int)), spinBox, SLOT(setValue(int)));
      	spinBox->setValue(20);
      
      	QHBoxLayout* layout = new QHBoxLayout;
      	layout->addWidget(spinBox);
      	layout->addWidget(slider);
      	window->setLayout(layout);
      
      	window->show();
      	return app.exec();
      }
      

      The demo package: http://u.163.com/vgTo1qYY Code: 3WCeCoYf

      Anyone has any idea what the problem might be?
      Thanks a lot.

      1 Reply Last reply Reply Quote 0
      • mrjj
        mrjj Lifetime Qt Champion last edited by

        Hi

        Seems all styles is stripped/not loading/failed.

        Try to print out
        qDebug() << QStyleFactory::keys().join(" ");

        Also I would try with
        http://doc.qt.io/qt-5/qtwidgets-painting-affine-example.html

        it uses a custom Style and if it also go missing
        it must mean/indicate that the Qt style fail in some regards
        when converted to Metro App.

        1 Reply Last reply Reply Quote 0
        • S
          Stak1945 last edited by

          Hi mrjj,
          Thanks for your reply.

          I tried the qDebug() and here is the result:
          Win32:
          Win32
          UWP:
          UWP
          Does it mean Win10 UWP Environment is a specialized unsupported version?

          The custom style works fine in our application in UWP environment, like this:
          Custom Style
          I didn't try the "qtwidgets-painting-affine-example" cause we are using Qt4 and don't have a Qt5 environment at hand. Thought the application screen short might be suffice to clear the point. So the Qt style is still working.

          What can I infer from the debug message? What further investigation can I take?
          Thank you.

          mrjj 1 Reply Last reply Reply Quote 0
          • mrjj
            mrjj Lifetime Qt Champion @Stak1945 last edited by

            @Stak1945
            HI
            Sadly the forum eats the pictures so i cannot see them. ( you can )
            Could you please upload to say postimage.org and post the links here.

            1 Reply Last reply Reply Quote 0
            • S
              Stak1945 last edited by

              Hi mrjj,

              Here are the pictures.
              Win32 Debug:
              Win32Debug
              UWP Debug:
              UWP Debug
              Custom Style of Our Application in UWP Environment:
              Custom Style of Our Application in UWP Environment

              Thank you:)

              mrjj 1 Reply Last reply Reply Quote 0
              • mrjj
                mrjj Lifetime Qt Champion @Stak1945 last edited by

                @Stak1945
                Thank you.
                Are they ment to be so small? ( even when clicked)

                1 Reply Last reply Reply Quote 0
                • mrjj
                  mrjj Lifetime Qt Champion last edited by

                  Hi
                  I don't know enough about modern apps and UWP to guess at this
                  but it seems to me that Qt4 seems to think its run in good old win32 and as far as
                  I understand what the converter does
                  then its running inside a legacy "wrapper"
                  So I would go and play with QStyle
                  http://doc.qt.io/qt-4.8/qstyle.html
                  and see if it changes anything.

                  Did you try a normal application ? does it also change look when converted ?

                  1 Reply Last reply Reply Quote 0
                  • S
                    Stak1945 last edited by

                    Strange. Didn't mean to be small. Sorry for that.
                    The debug message in Win32 is

                    "Windows WindowsXP WindowsVista Motif CDE Plastique Cleanlooks".
                    

                    The debug message in UWP is

                    Qt: Untested Windows version 10.0 detected!
                    "Windows Motif CDE Plastique Cleanlooks"
                    

                    What do you mean by normal application?
                    Our application is kind of big with probably hundred of dialogs in it, it there a way to fix them all in one place?

                    Thank you.

                    mrjj 1 Reply Last reply Reply Quote 0
                    • mrjj
                      mrjj Lifetime Qt Champion @Stak1945 last edited by

                      @Stak1945
                      Hi, np.

                      Ok so it seems related to Qt4 not knowing win 8+ and never seen the UWP
                      runtime environment.

                      • What do you mean by normal application?
                        As far as I understand, you can convert a desktop app to run in the modern runtime.
                        So I was wondering if you took a non Qt app and converted it and ran it , if it
                        would change the look too.

                      • Our application is kind of big with probably hundred of dialogs in it, it there a way to fix them all in one place?

                      if you set the QStyle then it will apply to all.
                      QApplication::setStyle();

                      Also, you can do
                      ./myapplication -style motif
                      but not sure its possible in UWP

                      So it seems that Qt4 is too old for the "modern" runtime and only style available
                      is "Windows" which might look like what u see.

                      I dont know what the fix is. :(

                      1 Reply Last reply Reply Quote 0
                      • S
                        Stak1945 last edited by Stak1945

                        @mrjj
                        Hi mrjj,

                        My colleague has figured out how to fix this:D
                        As it concerns with not recognizing Windows Version, adding corresponding windows version number to corelib/global/qglobal.h and .cpp fixed this issue.

                        Add Win10 support in enum WinVersion, enum MacVersion of qglobal.h and QSysInfo::windowsVersion() of qglobal.cpp.

                        Thanks for your help:)

                        mrjj 1 Reply Last reply Reply Quote 2
                        • mrjj
                          mrjj Lifetime Qt Champion @Stak1945 last edited by

                          @Stak1945
                          Super.
                          So app was confused what windows a modern universal app wrapper was actually running in :)
                          Thank you for reporting back. It will come up again :)

                          Oh, can I ask why Q4.8 ?
                          You already tons of code and porting it to Qt5.X is simply not
                          an option ? :)

                          1 Reply Last reply Reply Quote 0
                          • S
                            Stak1945 last edited by

                            @mrjj
                            Why Qt4? :)
                            It's because our application is 28 years old and during the latest refactoring about 5 or 4 years ago we introduced Qt4, really tons of code intertwined with customized Qt4 library. Porting to Qt5 may concern so much code to change and features to test so the plan has been postponed.
                            Guess a change to Qt5 will have to wait for another refactoring :D

                            1 Reply Last reply Reply Quote 1
                            • mrjj
                              mrjj Lifetime Qt Champion last edited by

                              Ah, yes. in 28 years, one can get quite the amount of code. :)
                              Well Qt4.8 should be good for years and besides you just ran it
                              in something really new and it worked. \o/

                              1 Reply Last reply Reply Quote 0
                              • First post
                                Last post