Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.4k Topics 456.4k Posts
  • how to set QDockWidget location

    Solved
    3
    0 Votes
    3 Posts
    580 Views
    D
    @SGaist code above works with minor changes, but only in the mingw 5.15.2 x32 compiler changes: control panel: //setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); all areas setFeatures(features() ^ QDockWidget::DockWidgetClosable ^ QDockWidget::DockWidgetFloatable); of course it work not fully right, control panel can placed at any corner, but i think i can connect to QDockWidget::dockLocationChanged and place it like i need after drag
  • 0 Votes
    3 Posts
    273 Views
    namakoN
    @JonB Thanks for the reply. I gave it a quick try and confirmed that it works as expected. I had no idea that such a flag existed. Thanks for the great info and for your kindness. (^^)
  • QQuickAsyncImageProvider not caching

    Unsolved
    6
    0 Votes
    6 Posts
    452 Views
    eyllanescE
    @ocgltd I do not understand you. The cache is just your speculation or you saw it somewhere in the Qt documentation. I ask because in your initial comment you say: According to the documentation QQuickAsyncImageProvider but in your last one it seems the opposite.
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    9 Views
    No one has replied
  • Questions of Qt Design Studio and QML

    Unsolved
    5
    0 Votes
    5 Posts
    368 Views
    mrjjM
    @Alby Just to clear up Qt is both QML and QWidgets. Can I make animations like those made with QML with Qt? If you mean with QWidgets, then to some degree but huge Widgets will flicker. QML does it much smoother. Can I modify and customize the window title bar with Qt? No. Not with Widgets nor QML. It's outside Qt and the best result comes from using native API. Its been asked lots of time and you can find examples on the net that show off a custom caption but most suffer (small) issues. You can hide the caption with Qt and draw your own but you lose resize and and dragging and it must all be hand coded.
  • [SOLVED] C# "Tag" equivalent for QT button

    Unsolved pushbutton
    4
    0 Votes
    4 Posts
    697 Views
    SGaistS
    Hi and welcome to devnet, You can mark your thread as solved either using the "Topic Tools" button or the three dotted menu beside the answer your deem correct :-) The title prefix was needed in a previous version of the forum.
  • QSyntaxHighlighter - no bold text?

    Unsolved
    10
    0 Votes
    10 Posts
    843 Views
    mrjjM
    Hi I'm very interested as I thought it was impossible with QPlainTextEdit to alter any of the blocks to have other formatting but it sounds like you actually did that. Well QPlainTextEdit has a higher level interface than QTextDocument where you really have to fiddle around with internal building blocks. thx for the code :)
  • problem with userdefined widget with qtcreator ...

    Unsolved
    6
    0 Votes
    6 Posts
    406 Views
    mrjjM
    @django-Reinhard Hi If the file (the .h file) with the custom widget is not directly with the .PRO file then you must add the relative path to the place where you give it the .h when you promote like subfolder/mywidget.h
  • 0 Votes
    3 Posts
    190 Views
    mrjjM
    Hi Another poster asked the same so you can look at this sample https://www.dropbox.com/s/l8go4t71unosl05/CrossTalk.zip?dl=0 It sends info from one window to the other using signal and slots
  • Display a std::string in a QLineEdit in QT

    Unsolved
    8
    0 Votes
    8 Posts
    1k Views
    JKSHJ
    @amadeok said in Display a std::string in a QLineEdit in QT: on my pc the second function which reads normally the utf8 file takes about 130ms, while the first that converts to wstring while reading took about 750ms. That doesn't tell us anything useful, because QString is completely different from std::wstring. I extended your test on a 13MB .txt file (created by duplicating https://www.w3.org/2001/06/utf-8-test/UTF-8-demo.html 10x): QString qreadFile(const char* filename) { QFile src(filename); src.open(QFile::ReadOnly|QFile::Text); return QString::fromUtf8(src.readAll()); } QString qreadFile2(const QString& filename) { QFile src(filename); src.open(QFile::ReadOnly|QFile::Text); QTextStream stream(&src); stream.setCodec("UTF-8"); return stream.readAll(); } std::wstring wreadFile(const char* filename) { std::wifstream wif(filename); wif.imbue(std::locale(std::locale::empty(), new std::codecvt_utf8<wchar_t>)); std::wstringstream wss; wss << wif.rdbuf(); return wss.str(); } std::string readFile(const char* filename) { std::ifstream in(filename); std::stringstream ss; ss << in.rdbuf(); return ss.str(); } On my PC (MSVC 2019 32-bit): Reading std::wstring took 676ms Reading std::string took 135ms Reading QString took 53ms (both versions) So reading the file as a QString is faster than reading it as a std::string.
  • This topic is deleted!

    Unsolved
    3
    0 Votes
    3 Posts
    27 Views
  • X and Y mouse position

    Unsolved
    5
    0 Votes
    5 Posts
    257 Views
    A
    Ok thank you
  • QMediaPlayer on background thread?

    Solved
    10
    0 Votes
    10 Posts
    811 Views
    mrjjM
    @davecotter Assuming "after my app imports a thousand songs" talks about videos and hence we would have no benefit from processing sound files then yes to " no, you cant"
  • Externl images are not visible when running the application

    Solved
    6
    0 Votes
    6 Posts
    285 Views
    C
    Ah, I deleted the files from the folder and added the assets again. This time it worked. Weird that it didn't last time. Thanks for the help though!
  • This topic is deleted!

    Unsolved
    1
    0 Votes
    1 Posts
    8 Views
    No one has replied
  • qt rfid serialport

    Moved Unsolved
    12
    0 Votes
    12 Posts
    3k Views
    R
    @veysel-olgun sir, please share rfid coding
  • Show an Ellipse Move Around a Point

    Unsolved
    3
    0 Votes
    3 Posts
    171 Views
    mrjjM
    Hi I would try the geopainter sample first https://invent.kde.org/education/marble/-/tree/master/examples/cpp/geopainter
  • Compiling in g++

    Unsolved
    4
    1 Votes
    4 Posts
    4k Views
    C
    I am going to assume you are using the Qt versions installed by the online installer. On Linux this creates a folder Qt containing one folder for each Qt library version you chose to install (and some other stuff to support Qt Creator). For example: chrisw@newton:~/Qt$ ls -l total 31492 drwxrwxr-x 3 chrisw chrisw 4096 Jun 8 2020 5.15.0 drwxrwxr-x 3 chrisw chrisw 4096 Jun 20 13:24 6.1.1 -rw-r--r-- 1 chrisw chrisw 10174 Jul 4 12:48 components.xml ... Inside each Qt version folder is a complete set of Qt library components and tools identified by compiler(s): chrisw@newton:~/Qt$ ls -l 5.15.0/ total 8 drwxrwxr-x 13 chrisw chrisw 4096 Jun 8 2020 gcc_64 -rw-rw-r-- 1 chrisw chrisw 2271 May 14 2020 sha1s.txt chrisw@newton:~/Qt$ ls -l 5.15.0/gcc_64/ total 76 drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 bin drwxr-xr-x 4 chrisw chrisw 4096 Jun 8 2020 doc drwxr-xr-x 88 chrisw chrisw 4096 Jun 8 2020 include drwxr-xr-x 5 chrisw chrisw 28672 Jun 8 2020 lib drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 libexec drwxr-xr-x 76 chrisw chrisw 4096 Jun 8 2020 mkspecs drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 phrasebooks drwxr-xr-x 33 chrisw chrisw 4096 Jun 8 2020 plugins drwxr-xr-x 23 chrisw chrisw 4096 Jun 8 2020 qml drwxr-xr-x 2 chrisw chrisw 4096 Jun 8 2020 resources drwxr-xr-x 3 chrisw chrisw 12288 Jun 8 2020 translations If you run the qmake executable from the ~Qt/5.15.0/gcc_64/bin folder against your PRO file it will generate a Makefile that uses the tools and library under ~Qt/5.15.0/gcc_64 and the (in this example) the 64-bit GCC compiler. When you run make your project will be built with those tools and libraries. A Windows install will be similar but you may need to ensure the bundled MingW bin folder is in your PATH. So, from top to bottom: chrisw@newton:/tmp/demo$ cat main.cpp #include <QCoreApplication> #include <QDebug> int main(int argc, char **argv) { QCoreApplication app(argc, argv); qDebug() << "Excellent!"; return 0; } A basic PRO file starter can be created for you (one time only, after that you maintain this file yourself): chrisw@newton:/tmp/demo$ ~/Qt/5.15.0/gcc_64/bin/qmake -project chrisw@newton:/tmp/demo$ cat demo.pro ###################################################################### # Automatically generated by qmake (3.1) Sat Aug 28 09:32:14 2021 ###################################################################### TEMPLATE = app TARGET = demo INCLUDEPATH += . # You can make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # Please consult the documentation of the deprecated API in order to know # how to port your code away from it. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 # Input SOURCES += main.cpp Then you create the Makefile: chrisw@newton:/tmp/demo$ ~/Qt/5.15.0/gcc_64/bin/qmake chrisw@newton:/tmp/demo$ ls demo.pro main.cpp Makefile and build the project: chrisw@newton:/tmp/demo$ make g++ -c -pipe -O2 -Wall -Wextra -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -I/home/chrisw/Qt/5.15.0/gcc_64/include -I/home/chrisw/Qt/5.15.0/gcc_64/include/QtGui -I/home/chrisw/Qt/5.15.0/gcc_64/include/QtCore -I. -isystem /usr/include/libdrm -I/home/chrisw/Qt/5.15.0/gcc_64/mkspecs/linux-g++ -o main.o main.cpp g++ -Wl,-O1 -Wl,-rpath,/home/chrisw/Qt/5.15.0/gcc_64/lib -o demo main.o /home/chrisw/Qt/5.15.0/gcc_64/lib/libQt5Gui.so /home/chrisw/Qt/5.15.0/gcc_64/lib/libQt5Core.so -lGL -lpthread chrisw@newton:/tmp/demo$ ./demo Excellent!
  • Incomprehensible crash maybe related to QT_CONFIG(accessibility)

    Unsolved
    2
    0 Votes
    2 Posts
    302 Views
    M
    In what file is that #ifdef QT_CONFIG(accessibility) line? Also, what is on the line before or after that? I don't think it can actually crash on a preprocessor directive line. What OS is this running on? I've noticed that MS Window's cdb debugger sometimes reports the wrong line that causes the crash (the actual line is either one before or one after).
  • Transparent Image not displaying correctly in QLabel

    Solved
    5
    0 Votes
    5 Posts
    871 Views
    DriftwoodD
    @raven-worx The checkered background, aside from other things, signifies image area that's transparent. By all rights, it shld vanish completely and allow the app bg color to fill in. I can only guess that some of the stock images were incorrectly created as being why I had trouble. But the last one, shown above, worked as expected. Thanks for your input. That's what got me thinking abt the legitimacy of the image's transparency.