Unsolved I have dimension companent problem on my phone
-
@Xander84 said in Qt on Android layouts all wrong:
QScreen *screen = qApp->primaryScreen();
m_dipScaleFactor = screen->physicalDotsPerInch() / screen->devicePixelRatio() / m_dipNorm;I have dimension companent problem on my phone ,small objects.Could you explain better how I can solve this problem.I am new at Qt. Thanks.
[Edit: The original thread is dead for many years now and the users who posted there aren't active on this forum anymore. Please elaborate on your problem and give your thread a meaningful title. ~~ @Wieland ]
-
Well, bump your scale factor. Or use QtQuick.Controls 2, which have DPI scaling fixed and done automatically.
Also, see the docs: link. That method is known to report dubious values on Android.
-
Okay ,but Can I use with C++ together.both C++ and QtQuick .Also How can I use Qtquick ,could you offer a source for this
-
Sure, you can use QML and C++ together. That's the point, actually ;-) To keep logic in C++ and UI in QML.
But now that you've asked that question, I am confused. Is your application built using QtWidgets module? Or are you building something fresh from scratch? If you're doing something new, it is a good idea to start with QtQuick, sure. If you already have an app written with widgets, it may be an overkill to try and rewrite it - then it would be better to just tweak your scale factor on Android and hope for the best.
-
I couldn't excatly understand ,what you mean,but I am gonna try to tell you my work.I choosed application selection -> Qt Widgets Application then -> next and-> Android for armeabi-v7a then my projects is opened.Base Class is choosed as QMainWindow.All I did is this and some forum application.
-
Widget applications are not very well suited for mobile platforms. You'll be better of starting a new project "Qt Quick application".
Also, to make the learning curve more enjoyable, I recommend reading https://qmlbook.github.io/
-
Thanks informations,
Last question(I think last question :) .When I created a button in Qt Quick ,then can I program it with C++ ,and other companents.Because I like using C++ and I would like to use mostly C++ -
@ZekDe yes, you can.
It is described in the link @sierdzio posted: https://qmlbook.github.io/en/ch16/index.html -
Okay now ,I did it with C++ using like this
int h = screenGeometry.height();
int w = screenGeometry.width();
int hh = (3*h/sf1) + h/sf_title + h/sf_bluetooth;
hh = h - hh;
//qreal qrlX = screen->physicalDotsPerInchX(); // tek eksende alma yeterli
//qreal qrlY = screen->physicalDotsPerInchY();
screenGeometry.setX(w);
screenGeometry.setY(h);/// \brief labelTitle /// QFont fontTitle("Courier", round(h/87), QFont::Bold); ui->labelTitle->setGeometry(w/sf1,h/sf1,w-w/sf1,h/sf_title); ui->labelTitle->setFont(fontTitle); ui->labelTitle->setStyleSheet(QStringLiteral("color: #0095d6")); ui->labelTitle->setAlignment(Qt::AlignHCenter);