Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • Qt win10 QMYSQL driver not loaded

    Solved
    9
    0 Votes
    9 Posts
    1k Views
    Christian EhrlicherC
    You should look for mysql libraries, not for ones from windows.
  • qDebug print missplaced in run - not in code sequence

    Unsolved
    2
    0 Votes
    2 Posts
    263 Views
    Christian EhrlicherC
    I don't see what's wrong here - qDebug() and std::cout are two completely different things so why should the order between those two match when it is printed to stdout?
  • Right way to store objects in container. How?

    Unsolved
    2
    0 Votes
    2 Posts
    160 Views
    SGaistS
    Hi, What kind of objects do you have in mind ?
  • Lost connection to MySQL server during query QMYSQL3: Unable to reset statement

    Unsolved
    6
    0 Votes
    6 Posts
    2k Views
    C
    The above method introduced another issue. Apparently bindValue escapes the special characters. I've looked for a function or example on how to do this manually without luck. Does anyone know if such function exists ?
  • Creating the concrete main window with items.

    Solved
    9
    0 Votes
    9 Posts
    809 Views
    Chris KawaC
    QDockWidget has a setWidget() method to set its contents. For the documents dock you can use QListWidget to list all the documents and for the File Browser see QTreeView and QFileSystemModel.
  • Text alignment on QTableWidgetItem

    Solved
    5
    0 Votes
    5 Posts
    5k Views
    S
    Hi mrjj, your solution works very fine. Many thanks :) Stefano
  • Howto activate the LowLatency on TCPClient on Windows

    Unsolved
    6
    0 Votes
    6 Posts
    766 Views
    aha_1980A
    @adib-taraben Thats probably because LowDelayOption is something different than you expect. So again the question: what do you measure (and how) resp. what is too slow for you. Regards
  • QlineEdit display of a string and a QDateTime variable.

    Unsolved
    8
    0 Votes
    8 Posts
    973 Views
    mrjjM
    Hi Its just QDateTime now = QDateTime::currentDateTime(); ui->lineEdit->setText( "Today is:" + now.toString() );
  • Passing Widget to annother Widget

    Solved
    11
    0 Votes
    11 Posts
    631 Views
    mrjjM
    @sandro4912 Hi Well if the rule is that a cell list will be owned by the minefield once given to it and will die with it i think it will work fine :)
  • QTreeView Loses Highlight when clicking on empty space

    Solved
    1
    0 Votes
    1 Posts
    221 Views
    No one has replied
  • QLineSeries + black color

    Unsolved
    1
    0 Votes
    1 Posts
    478 Views
    No one has replied
  • Center background image in QChart

    Unsolved charts qchart qchartview
    6
    0 Votes
    6 Posts
    4k Views
    F
    I found a solution and post it here: link
  • QOBject::tr() with floating-point number

    Solved
    5
    0 Votes
    5 Posts
    449 Views
    F
    @mpergand said in QOBject::tr() with floating-point number: QObject::tr("The value %1 is a double precision number").arg( my_double), Thank you @mpergand ! This solution works great!
  • QChart + background image

    Solved
    4
    0 Votes
    4 Posts
    4k Views
    F
    @mrjj thank you a lot! The original source-code of this old post was not working and it have a lot of warnings... So I modified to get a complete and zero errors/warnings modern Qt example. Here is the full source-code: #include "mainwindow.h" #include "ui_mainwindow.h" #include <QtCharts/QChartView> #include <QtCharts/QLineSeries> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent) , ui(new Ui::MainWindow) { ui->setupUi(this); //Build a series to add to the chart QtCharts::QLineSeries *series = new QtCharts::QLineSeries(); *series << QPointF(11, 1) << QPointF(13, 3) << QPointF(17, 6) << QPointF(18, 3) << QPointF(20, 2); //Create a chart object and format QtCharts::QChart *chart = new QtCharts::QChart(); chart->legend()->hide(); chart->addSeries(series); chart->createDefaultAxes(); chart->axes(Qt::Vertical).first()->setGridLineVisible(false); chart->axes(Qt::Horizontal).first()->setGridLineVisible(false); //Bring in the background image from Qt resource QImage skyplot(":/SkyPlot.jpg"); if (skyplot.isNull()) { return; } // ===== CHART VIEWER ===== // // Create a Chart Viewer: QtCharts::QChartView* chartView = new QtCharts::QChartView(); //Add the chart to the view widget chartView->setChart(chart); chartView->setRenderHint(QPainter::Antialiasing, true); //Note: Since we added the chart to the view we can now //scale and translate the image appropriately. The chart //has an appropriate size. //Grab the size of the plot and view areas int width = static_cast<int>(chart->plotArea().width()); int height = static_cast<int>(chart->plotArea().height()); int ViewW = static_cast<int>(chartView->width()); int ViewH = static_cast<int>(chartView->height()); //scale the image to fit plot area skyplot = skyplot.scaled(QSize(width, height)); //We have to translate the image because setPlotAreaBackGround //starts the image in the top left corner of the view not the //plot area. So, to offset we will make a new image the size of //view and offset our image within that image with white QImage translated(ViewW, ViewH, QImage::Format_ARGB32); translated.fill(Qt::white); QPainter painter(&translated); QPointF TopLeft = chart->plotArea().topLeft(); painter.drawImage(TopLeft, skyplot); //Display image in background chart->setPlotAreaBackgroundBrush(translated); chart->setPlotAreaBackgroundVisible(true); // Add widget to GUI: ui->gridLayout->addWidget(chartView); } 3 key points: In the UI file, you have to add a gridLayout to the MainWindow window. Add the charts in your *.pro file Qt += charts The background image must be in a Qt resource file The final result is this chart + a backgroud image: [image: d474cfe6-3659-4baf-8935-59ca8075ba3e.png]
  • Clicking two mouse buttons with QtTest

    Solved
    8
    0 Votes
    8 Posts
    853 Views
    S
    @Pablo-J-Rogina said in Clicking two mouse buttons with QtTest: Qt::MouseButton button That also does not work. I think you cannot combine it with or for Qt::MouseButton button only for Qt::MouseButtons buttons. Anyway i realized I have a error in the code I want to test. The test code is okay. I don't really need to press two buttons exactly at the same time. My code allows to have the buttons clicked with a short delay of 50ms. Then it still counts as clicked together. Here just for curiosity the code to test: The press event: if(!(event->buttons().testFlag(Qt::LeftButton) || event->buttons().testFlag(Qt::RightButton))) { return; } if(event->buttons().testFlag(Qt::LeftButton)) { mSingleMouseTimerLeft.start(); } else if (event->buttons().testFlag(Qt::RightButton)){ mSingleMouseTimerRight.start(); } const auto elapsedTime = mElapsedTimer.restart(); if(elapsedTime >= QApplication::doubleClickInterval()) { return; } if((mSingleMouseTimerLeft.isActive() && event->buttons().testFlag(Qt::RightButton)) || (mSingleMouseTimerRight.isActive() && event->buttons().testFlag(Qt::LeftButton))){ if(!isPressed()) { pressIfReleased(); mNeighboursPressed = true; emit pressNeighbours(); } for(QTimer* timer : { &mSingleMouseTimerRight, &mSingleMouseTimerLeft }) { timer->stop(); } } In constructor: constexpr auto intervall = 50; for(QTimer* timer : {&mSingleMouseTimerRight, &mSingleMouseTimerLeft}){ timer->setInterval(intervall); timer->setSingleShot(true); } connect(&mSingleMouseTimerLeft, &QTimer::timeout, this, &Cell::pressIfReleased); connect(&mSingleMouseTimerRight, &QTimer::timeout, this, &Cell::mark); So in Short if the user clicks Right and Left in less than 50ms after each other it counts as both buttons clicked together. The test code stays the same as posted Still i wonder why theres no method which Supports the ``Qt::MouseButtons buttons` to press 2 Buttons like you suggested simultaneously.
  • Create QGraphicsItems on top of QGraphicsView from QMainWindow

    Solved
    17
    0 Votes
    17 Posts
    2k Views
    H
    @Asperamanca No it's solved (that's why I removed it) "If you were a fool, you wouldn't be asking questions, but instead insisting that Qt is stupid, and you didn't need it anyway :-)" this is litteraly every one of my co-students. They all hate Qt so much, but it needs a lot of time and patience to get right in. I'm gonna keep trying, because I think you can create a lot of different things with it.
  • How QFile can read/write 8 different outputs/inputs using for loop.

    Unsolved
    9
    0 Votes
    9 Posts
    550 Views
    mrjjM
    @J-Hilk Thanks it hurt my soul too :)
  • How to import the Statement in our .qml file

    Solved
    7
    0 Votes
    7 Posts
    522 Views
    sankarapandiyanS
    yes i got it @jsulm
  • How to output QList to standard console ?

    Solved
    12
    0 Votes
    12 Posts
    6k Views
    JonBJ
    @AnneRanch said in How to output QList to standard console ?: qDebug ("DEBUG message %d, says: %s", BT_string_list.size(),BT_string_list.at(loop1).name()); runs but "prints" garbage That's because you have not looked up the syntax or examples of qDebug(). Always use the (excellent) documentation! Look at https://doc.qt.io/qt-5/qdebug.html. See how it always uses the << operator? So qDebug() << "DEBUG message " << BT_string_list.size() << ", says: " << BT_string_list.at(loop1).name();
  • Load image in custom QGraphicsView

    Unsolved
    5
    0 Votes
    5 Posts
    822 Views
    jsulmJ
    @hobbyProgrammer https://doc.qt.io/qt-5/qgraphicsview.html#mousePressEvent