Skip to content

General and Desktop

This is where all the desktop OS and general Qt questions belong.
83.6k Topics 457.7k Posts
  • I wanna Add a button in the end of QTableView , i tried these ways but didn't work

    Solved
    22
    0 Votes
    22 Posts
    3k Views
    M
    @dheerendra yes for sure i've checked it and make it as yours (initialized QSqlTableModel and QTableView in the header file) now i create another islolated header and cpp file and put the function i wanna do in them and also same problem that if i closed QTableView it closes the other class , it executes the function but also closes this is the link of files on GitHub : https://github.com/MOSTAFAEZZAT/QTableViewProlem Update : Sir this Problem is solved now it was because of initializing the next window by pointer not as usual object i.e : class MainWindow : public QMainWindow { Q_OBJECT public: explicit MainWindow(QWidget *parent = nullptr); ~MainWindow(); private slots: void on_pushButton_3_clicked(); void on_pushButton_4_clicked(); void on_pushButton_8_clicked(); private: Ui::MainWindow * ui; MainProcess mainprocess ; }; this is a piece of function which if the login done show the next Window else no if(qry->exec()) { if(qry->next()) { model->setQuery(*qry); QString S = qry->value(0).toString() + "Login Successed "; QMessageBox::information(this,"Result",S) ; hide(); // mainprocess = new MainProcess(this) ; mainprocess.show(); } else { QMessageBox::information(this,"Result","Sorry Try Again") ; qDebug() << qry->lastError(); } } so in previous it was like that MainProcess * mainprocess but pls i just wanna know why it was destroying this window(MainProcess) if i closed QTableView .. And Thank you so much in Advance
  • QSerialPort interface with arduino problem

    Solved
    4
    0 Votes
    4 Posts
    476 Views
    M
    @mrjj @aha_1980 ok thanks! will try later. really appreciate for the help.
  • 0 Votes
    3 Posts
    4k Views
    T
    @mrjj @mrjj said in I am not understanding why. " error: no match for 'operator=' (operand types are 'QVector<int>' and 'int') queue[rear++]=value; ^": you have to say (*queue)[rear++]=value; Thank you, bro build is fine now and I will make sure the queue is filled with zeros
  • This topic is deleted!

    Unsolved
    4
    0 Votes
    4 Posts
    37 Views
  • QComboBox for Equally named Items

    Solved
    5
    0 Votes
    5 Posts
    663 Views
    ModelTechM
    Well, the code I came up with seems to work. I think however that I need to store a QMap from the MySubClassedQObjectClass items to the corresponding QVariants in order to be able to call QComboBox::fromData but that is fine. Unless there is a better way for this. Anyway, I think this is a good solution! The only thing that does not work anymore is the alphabetic insertion into the QComboBox that I realized using QComboBox::setInsertPolicy(QComboBox::InsertAlphabetically). Is this a bug?
  • Refering to other coordinate systems QGraphicsItems

    Unsolved
    5
    0 Votes
    5 Posts
    596 Views
    S
    So im making a game that uses 4 figures for each player each player has a different color and the numbers of players can change from 2-4 players(The game is a simple version of Ludo).I'm using two own classes first the matchfield class where I wanna save the positions from each field(a matchfield has around 40 fields where the figures move through similiar to a Ludo gamefield) like I did here my houseFields(here matchfield.H) where the figures start etc. So my housefields are declared to the correct coordinate system here it works all fine.The first code below works correctly. The second one where I use ellipse.setPos(qreal ax,qreal ay) doesn't. It uses the coordinate system of the item and i don't want that I still wanna use the scene coordinate system.`So I can use only set my boardgame positions in my matchfield class and use it from every figur position. And just for undestanding I'm using an array of *figures ellipse[16] (because 16 is the max amount of figures with 4 players)`` // First code for(int playerCount=0;playerCount<player*4;playerCount++){ matchfield.ellipse[playerCount]=new figures(); matchfield.ellipse[playerCount]->nr=playerCount; matchfield.ellipse[playerCount]->setPen(pen); matchfield.ellipse[playerCount]->setRect(matchfield.H[playerCount].x(),matchfield.H[playerCount].y(),26,26); if(playerCount<=4){ brush.setColor(Qt::darkYellow);} if(playerCount>=4){ brush.setColor(Qt::darkGreen);} if(playerCount>=8){ brush.setColor(Qt::blue);} if(playerCount>=12){ brush.setColor(Qt::red);} matchfield.ellipse[playerCount]->setBrush(brush); scene->addItem(matchfield.ellipse[playerCount]); }; //Second code. Here is an example where i wanna use the scene coordinate system and not the local coordinate system from the QGraphicsitem void MainWindow::on_pushButton_2_clicked() { int i=ui->doubleSpinBox->value(); matchfield.ellipse[i-1]->setPos(0,200); }
  • How to draw circle with line pattern using QGraphicsScene

    Solved
    3
    0 Votes
    3 Posts
    6k Views
    M
    It just works for me very well. I just used QGraphicsLineItem instead QGraphicsRectItem. Thank you in advance
  • Upgrading from qt4 to qt5

    Solved
    5
    0 Votes
    5 Posts
    1k Views
    Christian EhrlicherC
    QObject::connect() now returns a QMetaObject::Connection and no boolean. So you have to rewrite your statement a little bit to use the operator bool(): http://doc.qt.io/qt-5/qmetaobject-connection.html#operator-bool if(!QObject::connect(m_qtmr, SIGNAL(timeout()), this, SLOT(update()) )) Or even better use the new signal/slot syntax: https://wiki.qt.io/New_Signal_Slot_Syntax/de
  • Qt Creator not opening ubuntu 14.04

    Unsolved
    2
    0 Votes
    2 Posts
    520 Views
    aha_1980A
    Hi @vasu_gupta, I'm sorry, but Ubuntu 14.04 is no longer supported by Qt Creator. I think, even Qt 5.11 is not fully supported. You can install the latest version on Ubuntu 16.04 or 18.04. For Ubuntu 14.04, the only possibility would be to install an older version from http://download.qt.io/official_releases/qtcreator
  • connecting overloaded signals to overloaded slots fails

    Solved
    6
    0 Votes
    6 Posts
    4k Views
    dheerendraD
    Missing bracket was the issue.
  • app.setFont not work in static build Qt

    Unsolved
    2
    0 Votes
    2 Posts
    305 Views
    Christian EhrlicherC
    You should read what needs to be done with resources when using static linking: http://doc.qt.io/qt-5/resources.html#using-resources-in-the-application
  • How to achieve high performance asynchronous table model update?

    Solved
    12
    0 Votes
    12 Posts
    3k Views
    dheerendraD
    @kshegunov Thanks for clarifications. Looks like my answer is misinterpreted. Model is not UI & I did not say this also. Model can be updated from View & this is not in the context of his question. Now, worker Thread is pulling the data. Since model is in another thread use signals & slots to update the model which is in another thread. This is the only thing I said in my answer.
  • Convert QStringList to multiple integers

    Solved
    4
    0 Votes
    4 Posts
    620 Views
    SGaistS
    This works fine: #include <QtDebug> #include <QStringList> int main(int argc, char *argv[]) { Q_UNUSED(argc); Q_UNUSED(argv); QStringList list{"1", "2", "3"}; for (const QString& value : list) { if (value == QStringLiteral("3")) { // Do something qDebug() << "Found"; } else { // Do other something qDebug() << "Nop" << value; } } return 0; }
  • Showing a message when hovering over a QTabBar

    Solved
    7
    0 Votes
    7 Posts
    835 Views
    mrjjM
    Hi QTabBar can show tips http://doc.qt.io/qt-5/qtabbar.html#setTabToolTip if thats enough. update: basic customization be be done with style sheet qApp->setStyleSheet("QToolTip { color: #ffffff; background-color: blue; border: 1px solid white; }"); http://doc.qt.io/qt-5/stylesheet-reference.html
  • Strange tab ordering

    Unsolved
    1
    0 Votes
    1 Posts
    210 Views
    No one has replied
  • video record tab not enabling in camera example project

    Unsolved
    5
    0 Votes
    5 Posts
    725 Views
    SGaistS
    Isn't this thread a duplicate of this one ?
  • OpenGL resources

    Unsolved
    7
    0 Votes
    7 Posts
    1k Views
    SGaistS
    AFAIK, the manipulation of the objects must always be done with a valid context so the current one.
  • BLE not working in ubuntu

    Unsolved qt5 qbluetooth qbluetoothdevic qbluetoothlocal
    2
    0 Votes
    2 Posts
    634 Views
    mrjjM
    Hi http://doc.qt.io/qt-5/qtbluetooth-index.html Do you have BlueZ 4.x/5.x installed ?
  • qlabel and qstring color

    Unsolved
    4
    0 Votes
    4 Posts
    398 Views
    Christian EhrlicherC
    Did you read the link? And if - did you read that QLabel::setText() accepts html?
  • Positioning QlineEdit on a QWidget without Layout Manager

    Unsolved
    12
    0 Votes
    12 Posts
    2k Views
    A
    As it turns out - using QSpacerItem for this task is not so trivial, at least not to me... At this point, you probably figured out what I am trying to do. I have a DWORD (which is actually a LineEdit - a subclass of QLineEdit), of width W points. The DWORD's "Fields Layout" (not to be confused with Qt's Layout Managers) is a QVector describing the breakdown of the DWORD: typedef std::pair<QString, int> Field; typedef QVector<Field> FieldsLayout; Where the QString is the name of the Field, and int is its bit-size. Assume that an instance of FieldsLayout always sums up to 32. In other words: // let 'fieldsLayout' be an instance of FieldsLayout int sum = 0; for (int i = 0; i < fieldsLayout.size() i++) sum += fieldsLayout[i].second; assert(sum == 32); // this assertion never fails Now suppose 'labels' is an instance of QVector<QLabel*>: QVector<QLabel*> labels; for (int i = 0; i < fieldsLayout.size() i++) labels.push_back(new QLabel(fieldsLayout[i].first)) Given the above, my goal is to have labels[i] span over fieldsLayout[i].second * W/32 points, and be positioned above its corresponding bits in the DWORD. Something along the line of: [image: aa58e59c-4595-4138-84b7-722928764483.png] Maybe I don't even need QSpacerItems? Maybe all I need is making sure that each QLabel spans over the correct amount of W/32? If so, how can that be achieved? Please advise. Thanks! CORRECTION I don't want the QLabel to span over the correct amount of W/32 (I just realized it's easy - all I need is to set the QLabel to a fixed size of fieldsLayout[i].second * W/32), but rather I want it to be positioned in the center of the correct amount of W/32: [image: 696a96d3-7215-4fe1-8f0f-2b8bde91c43f.png] (The QLabel should take the minimum size it needs to display the text, and to be in the center of fieldsLayout[i].second * W/32 space)